【发布时间】:2014-09-01 18:51:24
【问题描述】:
在我的一个应用程序中,我需要进行遮罩(将 1 张图像重叠到另一张图像)
在我的应用程序中,我必须将 1 个图像(位图)加载到 imageview,然后必须将一些框架应用于该图像,我为此使用了另一个 imageview...这完全可以工作
我的问题是.. 当我要保存位图时... 使用这段代码
public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bmOverlay.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator
+ "test.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
return bmOverlay;
}
我收到
但我需要它
【问题讨论】:
-
你需要为此使用Layer Drawable
-
你能给我一些链接吗?
标签: android bitmap overlap masking