Android Bitmap Size Get computeSampleSize(BitmapFactory.Options options, int target)

Here you can find the source of computeSampleSize(BitmapFactory.Options options, int target)

Description

compute Sample Size

Declaration

public static int computeSampleSize(BitmapFactory.Options options,
            int target) 

Method Source Code

//package com.java2s;

import android.graphics.BitmapFactory;

public class Main {
    public static int computeSampleSize(BitmapFactory.Options options,
            int target) {
        int w = options.outWidth;
        int h = options.outHeight;
        float candidateW = w / target;
        float candidateH = h / target;
        float candidate = Math.max(candidateW, candidateH);
        candidate = (float) (candidate + 0.0);
        if (candidate <= 1.0)
            return 1;
        return (int) candidate;
    }/*  w w w.j av  a2s  .  c o  m*/
}

Related

  1. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  2. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  3. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  4. computeInitialSampleSize( BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  5. computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  6. getBitmapSize(String filePath)
  7. getImageWH(String path)
  8. inSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  9. obtainBitmapSize(String pathName)