在我的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