我有这段代码可以从用户外部存储中获取位图
/**
* Get bitmap from input stream
* @param is
* @param reqWidth
* @param reqHeight
* @return Bitmap
*/
public static Bitmap decodeSampleBitmapFromStream(InputStream is, int reqWidth,
int reqHeight) {
BufferedInputStream bis = new BufferedInputStream(is);
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(bis, null, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth,
reqHeight);
try {
bis.reset();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeStream(bis, null, options);
}
它在大多数支持上都可以正常工作,但在某些支持上我有这个警告
07-23 21:06:32.355: D/PowerManagerService(2687): onSensorChanged: light value: 10
07-23 21:06:32.510: W/System.err(26270): java.io.IOException: Mark has been invalidated.
07-23 21:06:32.510: W/System.err(26270): at java.io.BufferedInputStream.reset(BufferedInputStream.java:371)
07-23 21:06:32.510: W/System.err(26270): at ant.fileExplorer.FileExplorerAdapter.decodeSampleBitmapFromStream(FileExplorerAdapter.java:168)
这是关于这部分
try {
bis.reset();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
而且我真的不明白不能执行。
谢谢你的帮助