Android Bitmap Size Get computeSampleSizeLarger(float scale)

Here you can find the source of computeSampleSizeLarger(float scale)

Description

compute Sample Size Larger

Declaration

public static int computeSampleSizeLarger(float scale) 

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 w w  w  .  jav  a2s. 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. computeInSampleSizeForMoment(Bitmap map, int newWidth, int newHeight)
  2. computeSampleSize(int width, int height, int minSideLength, int maxNumOfPixels)
  3. computeSampleSize(float scale)
  4. computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  5. computeSampleSizeLarger(int w, int h, int minSideLength)
  6. getBitmapSize(Bitmap bitmap)
  7. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  8. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  9. computeInitialSampleSize( BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)