Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在android中将base64转换为9 patch.png_Php_Android_Json_Nine Patch - Fatal编程技术网

Php 在android中将base64转换为9 patch.png

Php 在android中将base64转换为9 patch.png,php,android,json,nine-patch,Php,Android,Json,Nine Patch,我正在尝试将在我的php服务器上找到的几个图像发送到我的应用程序。这些图像是9个patch.png文件。为此,我在服务器上使用base64编码: $img = fread(fopen($filepath, "r"), filesize($filepath)); $bin_image = base64_encode($img); 稍后,我将其包装为json并发送到我的应用程序: echo json_encode($response); 在我的android应用程序上,我从响应的json获取图像

我正在尝试将在我的php服务器上找到的几个图像发送到我的应用程序。这些图像是9个patch.png文件。为此,我在服务器上使用base64编码:

$img = fread(fopen($filepath, "r"), filesize($filepath));
$bin_image = base64_encode($img);
稍后,我将其包装为json并发送到我的应用程序:

echo json_encode($response);
在我的android应用程序上,我从响应的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);
    ...
}
问题是,图像没有按照我的需要显示为9补丁png文件。我知道我需要将位图图像转换为png 9补丁文件,但我不知道如何。。。
有什么建议吗?

我在这篇文章中找到了解决方案:我使用Brian Griffey类很容易地将位图动态转换为九块补丁…

九块补丁是一个带有额外信息块的位图。您需要在服务器上拆分这些,然后使用NinePatch类再次将它们放在一起。好的。。。我该怎么做?