Android Bitmap Size Get computeSampleSizeLarger(int w, int h, int minSideLength)

Here you can find the source of computeSampleSizeLarger(int w, int h, int minSideLength)

Description

compute Sample Size Larger

Declaration

public static int computeSampleSizeLarger(int w, int h,
            int minSideLength) 

Method Source Code

//package com.java2s;

public class Main {
    public static int computeSampleSizeLarger(int w, int h,
            int minSideLength) {
        int initialSize = Math.max(w / minSideLength, h / minSideLength);
        if (initialSize <= 1)
            return 1;

        return initialSize <= 8 ? prevPowerOf2(initialSize)
                : initialSize / 8 * 8;/*from  ww  w .  j a v  a 2s  .  c  o  m*/
    }

    public static int computeSampleSizeLarger(float scale) {
        int initialSize = (int) Math.floor(1f / scale);
        if (initialSize <= 1)
            return 1;

        return initialSize <= 8 ? prevPowerOf2(initialSize)
                : initialSize / 8 * 8;
    }

    private static int prevPowerOf2(int n) {
        if (n <= 0)
            throw new IllegalArgumentException();
        return Integer.highestOneBit(n);
    }
}

Related

  1. computeInitialSampleSize( BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  2. computeInSampleSizeForMoment(Bitmap map, int newWidth, int newHeight)
  3. computeSampleSize(int width, int height, int minSideLength, int maxNumOfPixels)
  4. computeSampleSize(float scale)
  5. computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  6. computeSampleSizeLarger(float scale)
  7. getBitmapSize(Bitmap bitmap)
  8. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  9. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)