简体   繁体   English

转换回图像时未显示图像转换为字节

[英]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. 我遇到了同样的问题。从客户端发送的字符串与在服务器端收到的字符串不同。

Check this for solution 检查此解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在android中将图像转换为字节数组 - converting image to byte array in android Android:将可绘制图像转换为字节数组时的一些问题 - Android : some problems when converting drawable image to byte array 将以字符串格式从服务器接收的二进制数据(字节数组)转换回android中的图像 - Converting binary data (byte array) received from server in String format back to image in android 如何将图像转换为字节数组并将后字节数组转换为图像 - How to convert image to byte array and convert back byte array to image Android OutOfMemory将图像字节数组转换为Drawable - Android OutOfMemory converting image byte array into Drawable 在Java类中将图像转换为字节数组 - Converting an image into byte array in a Java class 在Android中将图像从drawable转换为字节数组 - Converting an image from drawable to byte array in Android 将位图图像转换为字节数组并存储到Mysql中 - Converting Bitmap Image to Byte Array and Store into Mysql 错误:类型不兼容:字节[]无法转换为整数。 图片中 - error: incompatible types: byte[] cannot be converted to int. in Image 前摄像头拍摄时显示的图像,但后摄像头拍摄时不可见的图像 - Image shown when taken by front camera but not visible when taken by Back camera
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM