Flex 中图像处理的撤消、重做功能

发布于 2024-08-18 07:51:33 字数 354 浏览 1 评论 0原文

因此,我设法学习了一些 Flex 并创建了一个小应用程序:

  • 将图像加载到图像组件
  • 转换图像(旋转、翻转)
  • 使用矩阵应用滤镜

现在我正在考虑创建一些撤消重做功能。 每次我进行转换/添加过滤器时,我都希望能够返回到上一个图像(在操作之前)。

我的想法是拥有一个数组并将前一个位图添加到堆栈中。 但我发现转换和过滤器之间存在一些差异 我还看到了 ImageSnapshot 以及我能做什么,它看起来就像我所追求的。

总的来说,我对 Flex 有点陌生,我希望这里有人能给我任何建议,并希望能提供一些指导。

感谢您的任何建议! 最好的问候,

So I managed to learn some Flex and created a small app that:

  • Loads an image to an Image component
  • Transform the image (rotate, flip) with the Matrix
  • Apply filter(s)

Now I am thinking about to create some undo redo functionality.
Each time I do a transformation / add an filter I want to be able to go back to the previous image (before the action).

My thought is to have an Array and add the previous bitmap to the stack.
But I see that there are some differences between transformations and filters
I have also seen the ImageSnapshot and whot i can do and it looks like what I am after.

I am a bit new to Flex in general and I hope someone here can give me any advice on this and hopefully som directions.

Thanks for any advice!
Best regards,

Ran

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

注定孤独终老 2024-08-25 07:51:33

我建议研究命令设计模式

本质上,您的数组将不包含图像,而是包含表示对图像进行的操作的标记。每个令牌都有足够的信息来撤消(和重做?)其操作。

var c:Command = new RotateCommand(90, CLOCKWISE);
c.doWork();
history.push(c);

// Undo
var c:Command = history.pop();
c.undoWork();

然后在命令中,大致:

public function doWork():void {
    var newTransform:Matrix = calculateTransform(angle, direction); // 90, CLOCKWISE
    image.transform.matrix.concat(newTransform);
}

public function undoWork():void {
    var newTransform:Matrix = calculateTransform(-angle, direction); // reverse operation
    image.transform.matrix.concat(newTransform);

I suggest looking into the Command design pattern.

Essentially, your array would contain not the image, but tokens representing the operation taken on the image. Each token would have enough information to undo (and redo?) its operation.

var c:Command = new RotateCommand(90, CLOCKWISE);
c.doWork();
history.push(c);

// Undo
var c:Command = history.pop();
c.undoWork();

then in the commands, roughly:

public function doWork():void {
    var newTransform:Matrix = calculateTransform(angle, direction); // 90, CLOCKWISE
    image.transform.matrix.concat(newTransform);
}

public function undoWork():void {
    var newTransform:Matrix = calculateTransform(-angle, direction); // reverse operation
    image.transform.matrix.concat(newTransform);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文