Android examples for Graphics:Bitmap Size
verify Bitmap by checking its size
//package com.java2s; import android.graphics.BitmapFactory; import android.text.TextUtils; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; public class Main { public static boolean verifyBitmap(InputStream is) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Object bis = is instanceof BufferedInputStream ? is : new BufferedInputStream(is); BitmapFactory.decodeStream((InputStream) bis, null, options); try {// w w w .j a v a2 s . c o m is.close(); } catch (IOException e) { e.printStackTrace(); } return options.outWidth > 0 && options.outHeight > 0; } public static boolean verifyBitmap(String path) { try { return !TextUtils.isEmpty(path) && verifyBitmap(new FileInputStream(path)); } catch (FileNotFoundException e) { e.printStackTrace(); return false; } } }