简体   繁体   English

Flex:通过属性Object在BitmapImage(flex 4.5)中显示图像?

[英]Flex: Show image in BitmapImage (flex 4.5) from property Object?

I need to show an image stored in a database. 我需要显示存储在数据库中的图像。 I'm mapping a C# class Digital, with a field public Byte[] Imagen, to an AS3 class Digital, with a property public Imagen:Object/ByteArray. 我正在将具有字段public Byte [] Imagen的C#类Digital映射到具有属性public Imagen:Object / ByteArray的AS3类Digital。 I'm using Fluorinefx as broker. 我正在使用Fluorinefx作为经纪人。

I'm trying with s:BitmapImage, assigning .source=Imagen, but graphic doesn't appear. 我正在尝试使用s:BitmapImage,分配.source = Imagen,但未显示图形。

Do I need to convert in some way the Imagen propery to be able to assign the BitmapImagen's source?? 我是否需要以某种方式转换Imagen属性才能分配BitmapImagen的源?

I'm using flex 4.5. 我正在使用flex 4.5。 Any help I'll appreciate. 任何帮助,我将不胜感激。

Edit: 编辑:

Debugging, the real error is: 调试时,真正的错误是:

TypeError: Error #1034: Type Coercion failed: cannot convert []@e49c629 to flash.utils.ByteArray. TypeError:错误#1034:类型强制转换失败:无法将[] @ e49c629转换为flash.utils.ByteArray。

This is the real problem, maybe an issue with Fluorinefx? 这是真正的问题,也许是Fluorinefx的问题?

Ok, this is how I workaround this, apparently exists some issue with Fluorine's C# byte[] type processing; 好的,这就是我的解决方法,这显然与Fluorine的C#byte []类型处理有关; something bad happens with this mapping: (AS3)ByteArray <== byte[] (C#). 此映射发生了一些不好的情况:(AS3)ByteArray <== byte [](C#)。

Refering to this answer from Pedro Cruz , I had to create another field in C# Digital class: 参考Pedro Cruz的这个答案,我不得不在C#Digital类中创建另一个字段:

FluorineFx.AMF3.ByteArray ImagenPresentation;

and use the BytesToByteArray suggested function to return this correct type (FluorineFx.AMF3.ByteArray) from the ImagenPresentation get property: 并使用建议的BytesToByteArray函数从ImagenPresentation get属性返回此正确的类型(FluorineFx.AMF3.ByteArray):

get 
   { 
        return BytesToByteArray(Imagen);
   }

Finally, this new field is mapped to ImagenPresentation:ByteArray in AS3. 最后,此新字段映射到AS3中的ImagenPresentation:ByteArray。

Kind a mess, but works!.. maybe this can help anyone else, thanks a lot. 有点混乱,但是行得通!..也许这可以帮助其他人,非常感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM