【发布时间】:2011-12-11 15:34:45
【问题描述】:
我正在使用该功能将两个位图文件相互融合,并且它也重叠。 我正在使用此函数将其覆盖在 OneAnother 上。
public static Bitmap combineImages(Bitmap cameraImage, Bitmap visionImage) { // can add a 3rd parameter 'String loc' if you want to save the new image - left some code to do that at the bottom
Bitmap finalImage = null;
int width, height = 0;
width = cameraImage.getWidth();
height = cameraImage.getHeight();
finalImage = Bitmap.createBitmap(width, height, cameraImage.getConfig());
Canvas canvas = new Canvas(finalImage);
canvas.drawBitmap(cameraImage, new Matrix(), null);
canvas.drawBitmap(visionImage, new Matrix(), null);
// this is an extra bit I added, just incase you want to save the new image somewhere and then return the location
/*String tmpImg = String.valueOf(System.currentTimeMillis()) + ".png";
OutputStream os = null;
try {
os = new FileOutputStream(loc + tmpImg);
finalImage.compress(CompressFormat.PNG, 100, os);
} catch(IOException e) {
Log.e("combineImages", "problem combining images", e);
}*/
return finalImage;
}
但在保存此图像后,我会显示这些图像要相互组合。它不是覆盖。我希望它相互叠加。
请告诉我这个函数哪里错了?? 谢谢。
【问题讨论】:
-
你想组合位图,就像一个覆盖另一个。
-
我的第一个图像是 cameraPicture 和 TransperentLayer 的第二个图像。所以我希望将第二个透明图像叠加到第一个图像上。
标签: android android-layout android-emulator android-widget android-ndk