CamanJS - 应用过滤器/操作后更改基础画布 [英] CamanJS - change underlying canvas after applying filters/manipulations

查看:230
本文介绍了CamanJS - 应用过滤器/操作后更改基础画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CamanJS是一个伟大的图书馆,用于在浏览器中进行实时图像处理。

CamanJS is a great library for doing live image manipulation in the browser.

我在预先存在的画布对象上使用Caman。如果用户返回我的网站的上一个区域,然后再次转到画布,我可能需要更改该画布上的图片。

I am using Caman on a pre-existing canvas object. I may need to change the image on that canvas if a user goes 'back' to a previous area of my site and then comes forward to the canvas again.

Caman出现以缓存其接收的第一图像数据,然后将画布锁定到其上下文。尝试在应用Caman后更改画布不会对画布产生任何可见的更改。

Caman appears to cache the first image data it receives and then 'locks' the canvas to its context. Attempts to change the canvas after applying Caman result in no visible change to the canvas.

如何在Caman之外更改画布数据,然后重新应用Caman过滤器?

How can we change our canvas data outside of Caman and then re-apply Caman filters?

推荐答案

我给Ryan( CamanJS 的创建者)有一个称为reloadCanvasData()的函数,可以通过调用来刷新Caman的图像数据缓存,同时对画布的原始上下文进行任何更改。以下是来源链接: https://github.com/meltingice/CamanJS /blob/master/src/core/caman.coffee#L387-L392

I emailed Ryan (creator of CamanJS) and he replied that there's a function called reloadCanvasData() that can be called to 'refresh' Caman's image data cache with any changes to the canvas's original context. Here's the source link: https://github.com/meltingice/CamanJS/blob/master/src/core/caman.coffee#L387-L392

这完美无瑕:存储您为画布创建的Caman实例,然后在任何后续运行中调用 .reloadCanvasData()

This worked perfectly: store the Caman instance you create for your canvas and then call .reloadCanvasData() on any subsequent runs. You'll then need to re-apply any Caman manipulations you desire.

我想要将此功能记录为google似乎不包含任何对它的引用。

I wanted to document this function as google doesn't appear to contain any references to it yet.

这篇关于CamanJS - 应用过滤器/操作后更改基础画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆