EaselJS export DisplayObject as bitmap

纵然是瞬间 提交于 2019-12-11 18:32:55

问题


I have a EaselJS Container object and I want to export its contents (children Bitmaps) as an image (similar to what you would do with ActionScript PNGEncoder.encode).

Is this possible? I have other object present that I don't want to export so exporting the full <canvas> wouldn't work.


回答1:


You can use the getCacheDataURL method to export any cached DisplayObject to an image data url.

http://jsfiddle.net/lannymcnie/jqfgynve/1/

bmp.cache(0,0,image.width,image.height);
var url = bmp.getCacheDataURL();
var img = new Image();
img.src = url;

Any time you cache an image, a canvas is created that is drawn in place of the image. This method calls toDataURL() on the cache-canvas, generating a data URL that can be passed to the source of an image.

Note that the toDataURL is not a super performant API.



来源:https://stackoverflow.com/questions/34148747/easeljs-export-displayobject-as-bitmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!