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: > > 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 <[email protected]> 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<http://developer.android.com/training/displaying-bitmaps/manage-memory.html#inBitmap>and >>> this >>> video <http://www.youtube.com/watch?v=rsQet4nBVi8> >>> <http://savefrom.net/?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrsQet4nBVi8&utm_source=chromelite&utm_medium=extensions&utm_campaign=link_modifier>and >>> it works perfect for >>> BitmapFactory.decodeResource<http://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeResource%28android.content.res.Resources,%20int,%20android.graphics.BitmapFactory.Options%29>, >>> >>> but not for >>> BitmapFactory.decodeFile<http://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeFile%28java.lang.String,%20android.graphics.BitmapFactory.Options%29>. >>> >>> 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 [email protected] >>> To unsubscribe from this group, send email to >>> [email protected] >>> 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 [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> Romain Guy >> Android framework engineer >> [email protected] >> > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

