问题
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