I am trying to send several images that are found on my php server to my app. The images are 9 patch .png files. For that, on my server I am encoding with base64:
$img = fread(fopen($filepath, "r"), filesize($filepath));
$bin_image = base64_encode($img);
and later on I wrap it up as a json and send it to my app:
echo json_encode($response);
on my android app I am getting the image from the responded json :
public ServerMsg(JSONObject response, ServerResponseTags responseTag) throws JSONException {
...
String image_str = response.getString(IMAGE);
byte[] imageAsBytes = Base64.decode(image_str.getBytes(), Base64.DEFAULT);
image = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length);
...
}
the problem is that the image isn't presented as 9 patch png file as I needed. I know that I need to convert the bitmap image into png 9 patch file but I don't know how... Any suggestions ?