|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Transfer images from .NET to Flash
by Alexandre Silva-4
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hello. I’ve been trying to transfer bitmap images
between server<->client. From Client to Server I was successful, following
this website: http://blog.bsoares.com.br/tag/fluorinefx But from the Server to the Client, I always get a
“Type Coercion failed: cannot convert (…) to
flash.utils.ByteArray.” The code in the server-side:
private Byte[] BitmapToBytes(Bitmap bitmap)
{
try
{
Byte[] byteArray;
using (MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byteArray = ms.ToArray();
}
return byteArray;
}
catch (Exception ex)
{
return new Byte[1];
}
} And in client side I receive the exact same byte[] (I
checked the length and some values and they matched), but I cannot cast it into
a ByteArray object. I tried several options, simply making a cast, or
using the result already as a ByteArray but it always throws that exception. Also I tried converting the object to ByteArray
using: bytes.writeObject(
result.Image ); But then, I get another bytearray and the Loader does
not recognize it as an image. Can anyone help me?? I can’t find information
on the internet about passing an image from .NET server to flash client!! I’m using AMF3 in FlourineFX… PS – Please moderators disregard my previous
post, as this email account was not registered yet, so the post was waiting for
approval… _______________________________________________ fluorine mailing list fluorine@... http://fluorine.thesilentgroup.com/mailman/listinfo/fluorine_fluorine.thesilentgroup.com |
|
|
Re: Transfer images from .NET to Flash
by philmk
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message You can try this: public static function toBitmapData(
width : Number, height : Number, ba : ByteArray ) : BitmapData { if(ba == null) return null; var bd : BitmapData
= new BitmapData(
width, height, true); try { ba.position = 0; var u:uint; for( var i:uint=0;
i<bd.width ; i++ ) for( var j:uint=0;
j<bd.height; j++ ) bd.setPixel32( i,
j, ba.readUnsignedInt() ); } catch (err:Error) { trace("toBitmapData:
" + err.message); } return bd; } You need to know the width and height of
the image, and you recreate the image from the bytes like so: var data:BitmapData
= toBitmapData(width, height, imageData); return new Bitmap(data); From:
fluorine-bounces@...
[mailto:fluorine-bounces@...] On Behalf Of Alexandre
Silva Hello. I’ve
been trying to transfer bitmap images between server<->client. From
Client to Server I was successful, following this website: http://blog.bsoares.com.br/tag/fluorinefx But
from the Server to the Client, I always get a “Type Coercion failed: cannot
convert (…) to flash.utils.ByteArray.” The
code in the server-side:
private Byte[] BitmapToBytes(Bitmap bitmap)
{
try
{
Byte[] byteArray;
using (MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byteArray = ms.ToArray();
}
return byteArray;
}
catch (Exception ex)
{
return new Byte[1];
}
} And
in client side I receive the exact same byte[] (I checked the length and some
values and they matched), but I cannot cast it into a ByteArray object. I
tried several options, simply making a cast, or using the result already as a
ByteArray but it always throws that exception. Also
I tried converting the object to ByteArray using: bytes.writeObject(
result.Image ); But
then, I get another bytearray and the Loader does not recognize it as an image. Can
anyone help me?? I can’t find information on the internet about passing an
image from .NET server to flash client!! I’m
using AMF3 in FlourineFX… PS
– Please moderators disregard my previous post, as this email account was not
registered yet, so the post was waiting for approval… _______________________________________________ fluorine mailing list fluorine@... http://fluorine.thesilentgroup.com/mailman/listinfo/fluorine_fluorine.thesilentgroup.com |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |