Newbie question. I have a byte array (of total length 1920 X 1080 X 4), with every 4 bytes holding constant alpha value of 0x80 (~ 50% translucency) and RGB triplet, I would like to convert it to a bitmap using BitmapFactory. BitmapFactory always returns a null bitmap in the code below.
byte[] rgbImage; // allocated and populated with data elsewhere
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.outWidth = 1920;
opts.outHeight = 1080;
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeByteArray(rgbImage, 0, 1920 * 1080 * 4, opts);
if(bitmap == null){
Log.e("TAG","bitmap is null");
}
What am I doing wrong? It seems that since any byte takes values in the range 0..255, even an arbitrary byte array would qualify as a RGB image, provided its dimensions made sense.