I Am Alpha Papa

Alan Partridge: Alpha Papa

Right, I think I may have found some code that will solve the transparency/alpha issue (taken verbatim from http://android.amberfog.com/?p=430):

Create empty bitmap with dimensions of original image and ARGB_8888 format:
int width = src.getWidth();
int height = src.getHeight();
Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

Copy pixels from source bitmap to the int array:
int[] pixels = new int[width * height];
src.getPixels(pixels, 0, width, 0, 0, width, height);

And set these pixels to destination bitmap:
dest.setPixels(pixels, 0, width, 0, 0, width, height);

I don’t know if this will definitely work, but it could well be a step in the right direction. I’m doing my best to avoid having to use a later API (in order to use bitmap.setHasAlpha(true)) to maximise the number of devices that the app is compatible with. Ideally I will be avoiding the use of Bitmap.Config.ARGB 4444 too, because any serious loss in quality is unacceptable.

NOTE: I should also do some immediate checks to see if getPixel() returns the exact same value that has just been set with setPixel() – this should instantly underline any problems we’re having with the formatting.

I’ll have a crack at this on Saturday morning anyway.

 

TRP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s