80,349
社区成员
发帖
与我相关
我的任务
分享
822 private boolean processImageFile(String path) {
823 try {
824 mBitmapOptions.outWidth = 0;
825 mBitmapOptions.outHeight = 0;
826 BitmapFactory.decodeFile(path, mBitmapOptions);
827 mWidth = mBitmapOptions.outWidth;
828 mHeight = mBitmapOptions.outHeight;
829 return mWidth > 0 && mHeight > 0;
830 } catch (Throwable th) {
831 // ignore;
832 }
833 return false;
834 }
479 public static Bitmap decodeFile(String pathName, Options opts) {
480 validate(opts);
481 Bitmap bm = null;
482 InputStream stream = null;
483 try {
484 stream = new FileInputStream(pathName);
485 bm = decodeStream(stream, null, opts);
486 } catch (Exception e) {
487 /* do nothing.
488 If the exception happened on open, bm will be null.
489 */
490 Log.e("BitmapFactory", "Unable to decode stream: " + e);
491 } finally {
492 if (stream != null) {
493 try {
494 stream.close();
495 } catch (IOException e) {
496 // do nothing here
497 }
498 }
499 }
500 return bm;
501 }
private boolean processImageFile(String path) {
try {
mBitmapOptions.outWidth = 0;
mBitmapOptions.outHeight = 0;
BitmapFactory.decodeFile(path, mBitmapOptions);
mWidth = mBitmapOptions.outWidth;
mHeight = mBitmapOptions.outHeight;
return mWidth > 0 && mHeight > 0;
} catch (Throwable th) {
// ignore;
}
return false;
}
BitmapFactory.Options newOpts = new BitmapFactory.Options();
newOpts.inJustDecodeBounds = true;//设置true表示只加载轮廓
BitmapFactory.decodeFile(srcPath, newOpts);//初始化newOpts
int width = newOpts.outWidth;
int height = newOpts.outHeight;