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:
and this is uploaded result :