Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsafe public struct TxtGFX
- {
- public short Size;
- public short Width;
- public short Height;
- public ushort* Image;
- }
- [StructLayout(LayoutKind.Sequential, Pack=1)]
- unsafe struct TxtGFXHeader
- {
- public int Magic;
- public short Width;
- public short Height;
- }
- public static void SaveGFX(TxtGFX Image, string Filename)
- {
- TxtGFXHeader Header;
- Header.Magic = FILE_MAGIC;
- Header.Width = Image.Width;
- Header.Height = Image.Height;
- // Write file header
- IFormatter formatter = new BinaryFormatter();
- Stream stream = new FileStream(Filename, FileMode.Create, FileAccess.Write);
- formatter.Serialize(stream, Header);
- stream.Close();
- // Write actual image
- UnmanagedMemoryStream writeStream = new UnmanagedMemoryStream((byte*)Image.Image, Image.Width * Image.Height * sizeof(ushort), Image.Width * Image.Height * sizeof(ushort), FileAccess.Write);
- byte[] nullArray = new byte[1];
- writeStream.Write(nullArray, 0, Image.Size);
- writeStream.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement