0

I Converted a Bitmap to String Format and posted it to Server via using Volley library .

This is method i used for convert bitmap to string:

 public String getStringImage(Bitmap bmp){
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
        byte[] imageBytes = baos.toByteArray();
        String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
        return encodedImage;
    }

I posted returned String value of this method to server , and in server side i get it by PHP :

<?php 
if(isset($_POST["img"]))
{
    $image=$_POST["img"];

    $path="../uploads/1.png";

    file_put_contents($path,base64_decode($image));
    echo "success";
}
?>

But the background of uploaded image (in PNG format) is black color.

how can i slove this problem ?


this is real PNG:

enter image description here

and this is uploaded result :

enter image description here

SAYE
  • 1,247
  • 2
  • 20
  • 47
  • Hi, I'm not sure, but maybe you want to take a look at [this](http://stackoverflow.com/a/5133915/6386583). Not the JPEG part but maybe the imgTag part. – G. Kalender May 27 '16 at 21:17
  • as you see , i uesd **CompressFormat** in PNG format before.in this line bmp.compress(Bitmap.CompressFormat.PNG, 100, baos); – SAYE May 27 '16 at 21:20

0 Answers0