I am developing an application with ffmpeg for decoding a media frame. I populated the Bitmap object with the decoding result and used ImageView.setImageBitmap to display the bitmap. It works well in Android 2.3, but it doesnβt work in Android 4.0 or higher. The code is simple:
imgVedio.setImageBitmap(bitmapCache);//FIXME:in 4.0 it displays nothing
Then I tried to write Bitmap to a file and reload the file for display.
String fileName = "/mnt/sdcard/myImage/video.jpg"; FileOutputStream b = null; try { b = new FileOutputStream(fileName); bitmapCache.compress(Bitmap.CompressFormat.JPEG, 100, b);// write data to file } catch (FileNotFoundException e) { e.printStackTrace(); } finally { try { if(b != null) { b.flush(); b.close(); } } catch (IOException e) { e.printStackTrace(); } } Bitmap bitmap = BitmapFactory.decodeFile(fileName); imgVedio.setImageBitmap(bitmap);
This works, but the performance is too poor. So can someone help me solve the problem?
source share