android 将 3 个位图保存为 1 个
我有一个可以拍照的应用程序。它创建 2 个子集位图,对这些位图进行变形处理,然后将子集作为叠加层放置在原始位图上。有没有办法将所有三个位图保存为一个(如手机屏幕上显示的那样)?我想将用户在屏幕上看到的内容保存为 SD 卡上的第四个位图?我有一种感觉,我做错了。
谢谢
[更新1]
@Override
public void onDraw(Canvas canvas){
super.onDraw(canvas);
Log.e(TAG, "******about to draw bgr ");
canvas.drawBitmap(bgr, 0, 0, null);
if (isLocked == true && bothCirclesInPlace == true){
if(overLay != null)
canvas.drawBitmap(overLay, centreX-radius, centreY-radius, null);
if(overLay2 != null)
canvas.drawBitmap(overLay2, centreA-radius, centreB-radius, null);
}
I've an app that takes a picture. It creates 2 subset bitmaps, processes these bitmaps with a distortion, then places the subsets over the original as overlays. Is there a way to save all three bitmaps as one (as it appears on the phone's screen)? I'd like to save what the user sees on the screen as a fourth bitmap on the sdcard? I've a feeling I've done this wrong.
Thanks
[update1]
@Override
public void onDraw(Canvas canvas){
super.onDraw(canvas);
Log.e(TAG, "******about to draw bgr ");
canvas.drawBitmap(bgr, 0, 0, null);
if (isLocked == true && bothCirclesInPlace == true){
if(overLay != null)
canvas.drawBitmap(overLay, centreX-radius, centreY-radius, null);
if(overLay2 != null)
canvas.drawBitmap(overLay2, centreA-radius, centreB-radius, null);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,可以叠加多个位图并保存为单个图像文件(PNG / JPEG / ..)。
一种方法是使用 Canvas 类。 Canvas 和 Paint 类定义了位图的叠加方式。
以下代码将演示将多个位图叠加到单个图像文件中。
沙什
Yes it is possible to overlay multiple bitmaps and save as a single image file (PNG / JPEG / ..).
One way is to use Canvas class. Canvas along with Paint class defines the way in which bitmaps are overlayed.
Following code will demonstrate multiple bitmap overlay into a single image file.
Shash
您可以尝试以下操作。
如果可以的话,将图像绘制到画布上:
You can try the following.
If you can, draw the images to a canvas:
您可以使用 Bitma.compress(..) 和 FileOutputStream 作为最后一个参数。
阅读外部存储,了解如何写入的说明SD 卡。
You can use Bitma.compress(..) with FileOutputStream as last argument.
Read about external storage for instructions on how to write to sd-card.