Flex - 获取位图
是否可以使用 ActionScript 从组件获取位图数据?
我动态加载图像。 onComplete 我创建一个 Flex Image 组件并将加载的图像添加到源中
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
{
var image:Image = new Image();
image.x = 0;
image.y = 0;
image.source = e.currentTarget.content;
canvas.addChild(image); // canvas is already added as an MXML element.
}
稍后我想创建一个新的 Image 组件并从第一个 Image 获取 bitmapData。
我已经尝试过这
canvas.getChildAt(0)
似乎给了我图像,但我不知道如何获取位图数据。
canvas.getChildAt(0).bitmapData;
给我一个编译错误“...未定义的属性”
有谁知道如何获取位图数据以便我可以在我的新图像组件中使用它?
预先感谢,
兰
Is it possible to get the bitmap data from a component using ActionScript?
I dynamically load an image.
onComplete I create a Flex Image component and add the loaded image to the source
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
{
var image:Image = new Image();
image.x = 0;
image.y = 0;
image.source = e.currentTarget.content;
canvas.addChild(image); // canvas is already added as an MXML element.
}
Later I want to create a new Image component and get the bitmapData from the first Image.
I have tried this
canvas.getChildAt(0)
Which seems to give me the Image, but I can not figure out how to get the bitmap data.
canvas.getChildAt(0).bitmapData;
gives me a compile error "... undefined property"
Does anyone know how ot get the bitmap data so I can use it in my new Image component?
Thanks in advance,
Ran
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 ImageSnapshot.captureBitmapData()
http://livedocs.adobe .com/flex/3/langref/mx/graphics/ImageSnapshot.html
Check out ImageSnapshot.captureBitmapData()
http://livedocs.adobe.com/flex/3/langref/mx/graphics/ImageSnapshot.html
Cliff 的回答将为您提供
Image
的屏幕截图;要获取图像的底层 BitmapData 而不进行屏幕截图,您可以尝试这也应该避免任何过滤器。
Cliff's answer will give you a screenshot of the
Image
; to get the underlying BitmapData for the image without doing a screenshot, you can tryThis should avoid any filters as well.
这应该可以做到。
This should do it.