Hi Folks,

What would be the best way to create a Bitmap from a raw pixel array?
I need to display an image whose source is an array of bytes
describing the pixels (RGB or grayscale).

I tried to use createBitmap() but in that case I need to create an int
array of colors from my byte array so that takes lots of memory for no
specific need. Specially for grayscale images.

=======================================================================
// Set bitmap array from decoded array
int i, j;
int dataSize = width*height;
int[] pixelIntData = new int[dataSize];

for( i=0; i<dataSize; i++ ) {
       pixelIntData[i] = Color.rgb((int)decodedByteArray[i],
(int)decodedByteArray[i], (int)decodedByteArray[i]);
}
Bitmap myBitmap = Bitmap.createBitmap(pixelIntData, width, height,
Bitmap.Config.ARGB_8888);
========================================================================

Also I do not have the right color doing so. I don't know how to check
what is returned by the Color() function.

Any help would be greatly appreciated,
Thanks
STN

-- 
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

Reply via email to