位图空例外

时间:2011-12-15 15:56:52

标签: android bitmap nullpointerexception bitmapfactory

Bitmap bmp, rotated;
InputStream stream = context.getContentResolver().openInputStream(uri);
bmp = BitmapFactory.decodeStream(stream); // stream does not equal null

Matrix mat = new Matrix();
mat.postScale(0.5f, 0.5f);
mat.postRotate((float)rotation); 
// rotation calculated using ExifInterface orientation attr. for example: 90
rotated = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mat, true);

使用上面的代码片段,有时bmp == null,我得到一个NullPointerException @ Bitmap.createBitmap ...我从相机活动中获取uri ..图像肯定会被保存。

如果这是问题,我会得到一个OutOfMemoryException吗?有没有人认为这有什么问题或改进方法?

0 个答案:

没有答案