Android Bitmap Size Get getImageWH(String path)

Here you can find the source of getImageWH(String path)

Description

get Image WH

Declaration

public static int[] getImageWH(String path) 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileInputStream;

import java.io.InputStream;

import android.graphics.BitmapFactory;

public class Main {
    public static int[] getImageWH(String path) {
        int[] wh = { -1, -1 };
        if (path == null) {
            return wh;
        }/*from  w  ww.j a  v a2 s. c o m*/
        File file = new File(path);
        if (file.exists() && !file.isDirectory()) {
            try {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inJustDecodeBounds = true;
                InputStream is = new FileInputStream(path);
                BitmapFactory.decodeStream(is, null, options);
                wh[0] = options.outWidth;
                wh[1] = options.outHeight;
            } catch (Exception e) {
            }
        }
        return wh;
    }
}

Related

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