如何在Android中吸取位图?位图、如何在、Android

由网友(大家都比较喜欢)分享简介:我试图找出如何利用android的位图,并保持这些变化的位图的副本撤消功能。I'm trying to figure out how to draw on a bitmap in android, and keep a copy of these changed bitmaps for an undo functio...

我试图找出如何利用android的位图,并保持这些变化的位图的副本撤消功能。

I'm trying to figure out how to draw on a bitmap in android, and keep a copy of these changed bitmaps for an undo function.

Bitmap b = ...
Paint p = new Paint();
canvas.drawBitmap(b, new Matrix(), null);
canvas.drawCircle(0,0,20,20);
//does Bitmap b have the circle drawn on it next time?

或如何得到位图后,它被画在与画布(我想preserve一叠位图与绘图画布应用的变化)?也许我会对此完全错误的。

Or how do I get the bitmap after its been drawn on with the canvas(I want to preserve a stack of bitmaps with the changes applied by canvas drawing)? Maybe I'm going about this entirely wrong.

推荐答案

使用new帆布(位图位图) 提供了画布位图这将包含绘图操作的结果。

Use new Canvas(Bitmap bitmap) to provide a Canvas with a Bitmap which will contain the result of your drawing operations.

位图,你利用你的画布 drawBitmap 将永远不会被修改。

The original Bitmap that you draw on your Canvas with drawBitmap will never be modified.

由用户来完成每一个操作之后,您可能:

After each operation done by the user you might:

保存在内存中进行的操作的列表 在保存中间结果到外部存储与Bitmap.com preSS

另一种方法可以是使用一个LayerDrawable堆叠在彼此的顶部连续绘图操作。你可以想像,允许用户禁用每个单独的操作完成。

Another approach could be to use a LayerDrawable to stack successive drawing operations on top of each other. You can imagine allowing the user to disable each individual operation done.

阅读全文

相关推荐

最新文章