Re: [android-developers] Reusing bitmaps for BitmapFactory.decodeFile and BitmapFactory.Options.inBitmap
But here still I am getting error, guessing at time of loading big images and if perfom any screen action event.
-- any suggestion here?
On Saturday, August 24, 2013 5:22:11 PM UTC+5:30, Alexey Danilov wrote:
On Saturday, August 24, 2013 5:22:11 PM UTC+5:30, Alexey Danilov wrote:
Bitmap is mutable, because I decode it with option inMutable=true. Bitmaps have same size, because I decode the same file. But your answer forces me to read docs more carefully and I realize my fail! The docs says:The source content must be in jpeg or png format (whether as a resource or as a stream)OMG! My images have GIF format.By the way thanks!
суббота, 24 августа 2013 г., 11:28:33 UTC+3 пользователь Romain Guy (Google) написал:Here is what the documentation says: "The current implementation necessitates that the reused bitmap be mutable and of the same size as the source content."Make sure the bitmap you are reusing is mutable.On Sat, Aug 24, 2013 at 12:07 AM, danik <dani...@gmail.com> wrote:My app decodes a lot of bitmaps from sd card, so I want to reuse existing bitmaps to decrease GC work. I see examples from Android Training and this video and it works perfect forBitmapFactory.--decodeResource , but not for BitmapFactory.decodeFile. I use next code:private void testBitmapReusing() { BitmapFactory.Options options = newOptions(); Bitmap bitmap = decode(options); options.inBitmap = bitmap; bitmap = decode(options); } private BitmapFactory.Options newOptions() { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 1; options.inMutable = true; return options; } private Bitmap decode(BitmapFactory.Options options) { return BitmapFactory.decodeFile("/
mnt/sdcard/sun.jpg" , options); // return BitmapFactory.decodeResource(getResources(), R.drawable.sun, options); }Commented code (BitmapFactory.decodeResource) works as expected, it decodes new bitmap using existing bitmap. But uncommented code (BitmapFactory.decodeFile) doesn't decode new bitmap. It just writes to log message "E/BitmapFactory: Unable to decode stream: java.lang.IllegalArgumentException: Problem decoding into existing bitmap"
So where is my mistake?
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
--
Romain Guy
Android framework engineer
roma...@android.com
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home