简体   繁体   中英

C# Image AS3 ByteArray

I'm looking for the conventer from normal image in C# to AMF3 ByteArray . The image format is JPG, I'm using FluorineFX library to serialize and de-serliazize AMF3 Data.

I need to get image ByteArray in C# from JPG because I'm using this to my flash game, and I don't know how to serialize image to AMF3 ByteArray . There isn't much info on FluorineFX neither AMF3 C# ByteArray .

According to old FluorineFX Documentation if you want to convert image to byte array you need to use byte[] (variable types ending with [] are arrays) or FluorineFx.AMF3.ByteArray. byte[] Example code:

public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
    MemoryStream ms = new MemoryStream();
    imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
    return ms.ToArray();
}

public Image byteArrayToImage(byte[] byteArrayIn)
{
    MemoryStream ms = new MemoryStream(byteArrayIn);
    Image returnImage = Image.FromStream(ms);
    return returnImage;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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