在我的android应用程序中,我想将图像转换为字节并对其进行编码。并发送到数据库。但是当我将其转换回图像时,它不显示。请help.and告诉我在哪里我就在服务器端犯错误当转换回图像时转换为字节的图像
final Bitmap image=(images.get(position));
int size = image.getRowBytes() * image.getHeight();
ByteBuffer buffer = ByteBuffer.allocate(size); //Create a new buffer
image.copyPixelsToBuffer(buffer); //Move the byte data to the buffer
byte[] array = buffer.array();
encodedImageString = Base64.encodeToString(array, Base64.DEFAULT);
现在,当我解码此编码和imagestring写它,它不显示图像。
Byte[] imageByteArary= base64.decode(encodedImageString);
File myfile=new File("D://test1.jpg");
myfile.createNewFile();
FileOutputStream fOut=new FileOutputStream (myfile);
fOut.write(imageByteArray);
fOut.close();
'copyPixelsToBuffer()'不会创建一个JPEG格式。 – SLaks