[英]Image Converted to Byte not shown when Converting back to Image
In my android application , i want to convert image into bytes and encode it. 在我的android应用程序中,我想将图像转换为字节并对其进行编码。 and send to database. 并发送到数据库。 But when i convert it back on image, it do not show. 但是,当我将其转换回图像时,它不显示。 Please help.and tell me where i am making mistake 请帮助。告诉我我在哪里出错
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);
Now on the server side when i decode this encoded imageString and write it, it do not display image. 现在在服务器端,当我解码此编码的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();
I was facing the same problem.The String that you send from client side is not same what you receive at server side. 我遇到了同样的问题。从客户端发送的字符串与在服务器端收到的字符串不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.