在我的 android 应用程序中,我想将从相机拍摄的图像转换为字节数组并转换回位图以在图像视图中查看。我可以通过 Bitmap.compress 轻松完成。但我想在没有 Bitmap.compress 的情况下做到这一点。问题是我得到白线(每次图像都很差(线))
Bitmap hello; //image coming from camera
ByteBuffer buffer = ByteBuffer.allocate(hello.getByteCount());
hello.copyPixelsToBuffer(buffer);
byte[] bytes1 = buffer.array();
byte [] Bits = new byte[bytes1.length*4];
int i;
for(i=0;i<bytes1.length;i++)
{
Bits[i*4] =
Bits[i*4+1] =
Bits[i*4+2] = (byte) ~bytes1[i]; //Invert the source bits
Bits[i*4+3] = -1;//0xff, that's the alpha.
}
Bitmap bmimage = Bitmap.createBitmap( 360,248, Bitmap.Config.ARGB_8888);
bmimage.copyPixelsFromBuffer(ByteBuffer.wrap(Bits));
imageView11.setImageBitmap(bmimage);