I have a bitmap and I am trying to get the the data to be an rgba byte array. I can do bmp.getPixels
but this is not in rgba bytes. My end destination was to feed this to an HTML5 canvas which requires an 4 elements (r, g, b, a) per pixel. Is this possible?
This is the code I am using to get my bmp:
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
// can do bmp.getPixels here but it doesnt give RGBA :(
I tried this:
bmp.copyPixelsToBuffer(ByteBuffer.wrap(buffer));
but the contents of buffer is extremely weird, it doesnt look like rgba to me, it looks like this:
[ 54, 59, 64, -1, 54, 59, 64, -1,
Those -1
s especially look weird.