My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 16211: Creating a Bitmap from already existing Bitmap doesn't preserve original Bitmap config.
1 person starred this issue and may be notified of changes. Back to list
Status:  Released
Owner:  ----
Closed:  Apr 2011


Sign in to add a comment
 
Reported by alexjiro...@gmail.com, Apr 18, 2011
Given a source bitmap with ARGB_8888 config I wanted to create another bitmap that is a subset of the source one.

Using Bitmap.createBitmap(src, x, y, width, height) produces another bitmap, BUT the config is RGB_565.

Why is the original config not passed on to the new image? After all it is created from that source so the config should be preserved as only a subset of pixel is copied and not changed in any way!

The only way to fix this, that I found anyway, is to create another bitmap with the same width and height as smaller bitmap and ARGB_8888 config and copy data over. But that's just a hack.

Apr 18, 2011
#1 alexjiro...@gmail.com
Sorry should have said this is running on level 8 API but the method is since level 1. So I guess this is everywhere.
Apr 26, 2011
#2 alexjiro...@gmail.com
Another update. I don't really understand how to get the Bitmap.java from the android git (if someone let me know I will happily do it), but I had a look at the source from GrepCode and particular lines of code that I am talking about are 424 and 435. 

It checks if the bitmap has alpha when it sets the config internally. For some reason the public void setHasAlpha(boolean) is not exposed from the java API in order to set alpha. So is there a particular reason why config is not directly copied from source to destination and checked using hasAlpha method, even though there is no direct access to Bitmap?
Apr 26, 2011
#3 alexjiro...@gmail.com
Almost a duplicate of  Bug 13038 .
Apr 26, 2011
#4 romaingu...@gtempaccount.com
Fixed in 3.0
Status: Released
Apr 26, 2011
#5 ebom...@gmail.com
I'd say this IS a duplicate of 13038, which can now be closed. Thanks for the fix Romain!
Sign in to add a comment

Powered by Google Project Hosting