0

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 ?

4

1 回答 1

0

我在这篇文章中找到了解决方案:在运行时创建 NinePatch/NinePatchDrawable,我使用 Brian Griffey 类非常容易地将位图转换为九个补丁...

于 2013-08-23T21:07:34.097 回答