我正在尝试在Android中访问图像的原始像素数据。
代码大致如下:
代码大致如下:
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();
线性一维缓冲区buffer.array()
中的像素是如何存储的?
- 第一个元素是左上角像素还是左下角像素(或其他)?
- 按行主序(逐行)还是按列主序(逐列)?
- 通道顺序为ARGB还是BGRA?
- 每个通道单独按行主序还是按列主序?
- 其他内容