Can someone please explain to me what a mutable bitmap is? What advantages/disadvantages or what limitations do mutable and immutable bitmaps have?
Options options = new BitmapFactory. Options(); options. inMutable=true; myBitmap=BitmapFactory. decodeFile(filePath,options);
A bitmap is simply a rectangle of pixels. Each pixel can be set to a given color but exactly what color depends on the type of the pixel. The first two parameters give the width and the height in pixels. The third parameter specifies the type of pixel you want to use.
You can do a check when you want to return the BitMap look to see if the ArrayList of Paths is bigger than 0 and return the BitMap if so, or else return null.
Choose the most appropriate decode method based on your image data source. These methods attempt to allocate memory for the constructed bitmap and therefore can easily result in an OutOfMemory exception. Each type of decode method has additional signatures that let you specify decoding options via the BitmapFactory.
It's about the same difference as with String vs StringBuilder - String is immutable so you can't change its content (well at least not without any hacks), while for StringBuilder you can change its content.
In order to convert an immutable bitmap to a mutable one, check out this post: https://stackoverflow.com/a/16314940/878126.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With