C#图像AS3字节数组

问题描述 投票:0回答:1

我正在寻找C#中从普通图像到AMF3字节数的转换器。图像格式为JPG,我使用FluorineFX库对AMF3数据进行序列化和去序列化。我需要在C#中从JPG中获取图像ByteArray,因为我正在用它来制作我的Flash游戏,我不知道如何将图像序列化为AMF3 ByteArray。在FluorineFX上没有太多信息,也没有AMF3 C# ByteArray。谁能帮帮我?Cheers.

c# visual-studio amf fluorinefx
1个回答
1
投票

根据旧的FluorineFX文档,如果你想将图像转换为字节数组,你需要使用字节[](以[]结尾的变量类型是数组)或FluorineFx.AMF3.ByteArray.byte[]示例代码。

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;
}
© www.soinside.com 2019 - 2024. All rights reserved.