【发布时间】:2013-08-07 20:05:05
【问题描述】:
我通过这样做获得了我的 ARGB_8888 位图的像素数据:
public void getImagePixels(byte[] pixels, Bitmap image) {
// calculate how many bytes our image consists of
int bytes = image.getByteCount();
ByteBuffer buffer = ByteBuffer.allocate(bytes); // Create a new buffer
image.copyPixelsToBuffer(buffer); // Move the byte data to the buffer
pixels = buffer.array(); // Get the underlying array containing the data.
}
但是,我想将每个像素存储在四个字节 (ARGB) 上的数据转换为每个像素存储在 3 个字节上的数据 (BGR)。
任何帮助表示赞赏!
【问题讨论】:
-
我不认为
pixels = buffer.array()能达到你的预期。您是要返回像素数组,还是将它们复制到预先分配的像素数组中? -
"pixels" 是一个预分配的像素数组
标签: java android image bitmap bytebuffer