我的问题是:
我需要创建一个使用NinePatch创建的重新缩放的位图。
我的当前系统从NinePatch文件创建一个位图。然后将其提供给NinePatch(或NinePatchDrawable)。然后我需要调整大小并输出到另一个位图。
我已经查看了this,它帮助了我很多。
这是我的当前代码:
我需要创建一个使用NinePatch创建的重新缩放的位图。
我的当前系统从NinePatch文件创建一个位图。然后将其提供给NinePatch(或NinePatchDrawable)。然后我需要调整大小并输出到另一个位图。
我已经查看了this,它帮助了我很多。
这是我的当前代码:
try {
Bitmap bitmap1 = BitmapFactory.decodeStream(getAssets().open("gfx/head.9.png"));
// Using NinePatch?
NinePatch patch = new NinePatch(bitmap1, bitmap1.getNinePatchChunk(), null);
// Or NinePatchDrawable?
NinePatchDrawable patch = new NinePatchDrawable(bitmap1, bitmap1.getNinePatchChunk(), new Rect(), null);
// Set dimensions from NinePatch and create new bitmap
// Bitmap bitmap2 = ?
}
catch (IOException e) {
e.printStackTrace();
}
NinePatchDrawable
构造函数已经被弃用了 - 要使用非弃用版本,请将context.getResources()
作为第一个参数传递(在bitmap
之前)。 - VinceFior