无法从 Flex Air AS3 中删除的图像中获取位图数据
当我将图像拖放到画布上时,我可以获取图像的 nativePath,但不能获取我需要的位图数据。
在调试模式下,当我查看文件属性时,数据设置为 NULL。
我在这里做错了什么?在我的代码中 file.data
没有给我任何东西。
protected function creationCompleteHandler(event:FlexEvent):void
{
this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragIn);
this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,onDrop);
NativeDragActions.COPY;
}
private function onDrop(e:NativeDragEvent):void
{
trace("Dropped!");
var dropfiles:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var file:File in dropfiles){
switch (file.extension.toLowerCase()){
case "png" :
trace('png');
//resizeImage(file.nativePath);
break;
case "jpg" :
trace('jpg');
//resizeImage(file.nativePath);
break;
case "jpeg" :
trace('jpeg');
//resizeImage(file.nativePath);
break;
case "gif" :
resizeImage(file.nativePath);
break;
default:
Alert.show("choose an image file!");
}
}
}
When I drop an image onto my canvas I can get the nativePath to the image but not the bitmapdata which is the one I need.
In debug mode when I look into the file properties the data is set to NULL.
What am I doing wrong here? In my code file.data
doesn't give me anything.
protected function creationCompleteHandler(event:FlexEvent):void
{
this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragIn);
this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,onDrop);
NativeDragActions.COPY;
}
private function onDrop(e:NativeDragEvent):void
{
trace("Dropped!");
var dropfiles:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var file:File in dropfiles){
switch (file.extension.toLowerCase()){
case "png" :
trace('png');
//resizeImage(file.nativePath);
break;
case "jpg" :
trace('jpg');
//resizeImage(file.nativePath);
break;
case "jpeg" :
trace('jpeg');
//resizeImage(file.nativePath);
break;
case "gif" :
resizeImage(file.nativePath);
break;
default:
Alert.show("choose an image file!");
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您必须加载字节数组:
接下来,使用以下方式加载位图:
最后,获取位图
first, you have to load the bytearray:
next, load the bitmap using:
finally, get the bitmap