2
我試圖得到一個PIC只用後面的代碼凸輪做到了,但我一直同樣的錯誤:BitmapFactory.decodeStream總是返回NULL
skia(446): --- SkImageDecoder::Factory returned null
(它不會拋出例外)。因此,對象位圖始終爲NULL,我無法看到使用凸輪創建的圖片,而我可以使用Eclipse的文件瀏覽器查看該圖片。
發生了什麼事?我怎樣才能解決這個問題?
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.view_photo);
ImageView imagen = (ImageView)findViewById(R.id.foto);
try {
Cursor cur = this.getContentResolver().query(Media.EXTERNAL_CONTENT_URI, null, null, null,null);
String str = cur.getString(cur.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
cur.moveToLast();
FileInputStream in = new FileInputStream("/sdcard/DCIM/Camera/" + str);
BufferedInputStream buf = new BufferedInputStream(in, 24);
Bitmap bMap = BitmapFactory.decodeStream(buf);
if (bMap != null)
imagen.setImageBitmap(bMap);
else{
Log.d("onCreate: ", "bMap es NULL");
}
if (in != null) {
in.close();
Log.d("onCreate: ", "in cerrado");
}
if (buf != null) {
buf.close();
Log.d("onCreate: ", "buf cerrado");
}
Log.d("onCreate: ", "Fin del proceso");
}catch (Exception e) {
Log.e("Error reading file", e.toString());
}
}