I m trying to access the raw pixel data of an image in Android.
The code looks something like this:
Bitmap bitmap = BitmapFactory.decodeFile("image.png");
// assert valid input
if ((bitmap.getConfig() == null) || bitmap.getConfig() == Config.ARGB_8888)
throw new Exception("bad config");
ByteBuffer buffer = ByteBuffer.allocate(4 * bitmap.getWidth() * bitmap.getHeight());
bitmap.copyPixelsToBuffer(buffer);
return buffer.array();
如何储存1D条线的颜料?
- First element is top-left pixel or bottom-left pixel (or something else)?
- Row-major (row after row) or column-major (column after column)?
- Channel order ARGB or BGRA?
- Row-major or column-major for each channel separately?
- Something else