List of utility methods to do Bitmap Size Get
int | bitmapSize(Bitmap bitmap) bitmap Size if (bitmap == null) { return 0; return bitmap.getRowBytes() * bitmap.getHeight(); |
int | calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) calculate In Sample Size final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; while ((halfHeight / inSampleSize) > reqHeight && (halfWidth / inSampleSize) > reqWidth) { ... |
int | calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) calculate In Sample Size final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if ((reqWidth > 0 && reqHeight > 0) && (height > reqHeight || width > reqWidth)) { if (width > height) { inSampleSize = Math.round((float) height / (float) reqHeight); ... |
int | calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) calculate In Sample Size final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { final int heightRatio = Math.round((float) height / (float) reqHeight); final int widthRatio = Math.round((float) width / (float) reqWidth); ... |
int | computeInitialSampleSize( BitmapFactory.Options options, int minSideLength, int maxNumOfPixels) compute Initial Sample Size double w = options.outWidth; double h = options.outHeight; int lowerBound = (maxNumOfPixels < 0) ? 1 : (int) Math.ceil(Math .sqrt(w * h / maxNumOfPixels)); int upperBound = (minSideLength < 0) ? 128 : (int) Math.min( Math.floor(w / minSideLength), Math.floor(h / minSideLength)); if (upperBound < lowerBound) { ... |
int | computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels) compute Sample Size int initialSize = computeInitialSampleSize(options, minSideLength, maxNumOfPixels); int roundedSize; if (initialSize <= 8) { roundedSize = 1; while (roundedSize < initialSize) { roundedSize <<= 1; } else { roundedSize = (initialSize + 7) / 8 * 8; return roundedSize; |
int | computeSampleSize(BitmapFactory.Options options, int target) compute Sample Size 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; ... |
BitmapSize | getBitmapSize(String filePath) get Bitmap Size Options options = new Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(filePath, options); return new BitmapSize(options.outWidth, options.outHeight); |
int[] | getImageWH(String path) get Image WH int[] wh = { -1, -1 }; if (path == null) { return wh; File file = new File(path); if (file.exists() && !file.isDirectory()) { try { BitmapFactory.Options options = new BitmapFactory.Options(); ... |
int | inSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) in Sample Size final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { if (width > height) { inSampleSize = Math.round((float) height / (float) reqHeight); } else { ... |