0

In my android application , i want to convert image into bytes and encode it. 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.

                           Byte[] imageByteArary= base64.decode(encodedImageString);
                           File myfile=new File("D://test1.jpg");
            myfile.createNewFile();
            FileOutputStream fOut=new FileOutputStream (myfile); 
            fOut.write(imageByteArray);
            fOut.close();
4

1 回答 1

0

我遇到了同样的问题。您从客户端发送的字符串与您在服务器端收到的字符串不同。

检查此解决方案

于 2013-10-30T13:11:38.260 回答