Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static byte[] FILE_MAGIC = { //0x54474658
- (byte)'T', (byte)'G', (byte)'F', (byte)'X'
- };
- public static void SaveGFX(TxtGFX Image, string Filename)
- {
- Stream stream = new FileStream(Filename, FileMode.Create, FileAccess.Write);
- BinaryWriter Output = new BinaryWriter(stream);
- // Write header file
- Output.Write(FILE_MAGIC);
- Output.Write(Image.Width);
- Output.Write(Image.Height);
- // Write actual image
- Output.Write(PtrToByteArray((byte*)Image.Image, Image.Size));
- stream.Close();
- }
- private static byte[] PtrToByteArray(byte* DataPointer, short Size)
- {
- byte[] OutArray = new byte[Size];
- for (int X = 0; X < Size; X++)
- {
- OutArray[X] = DataPointer[X];
- }
- return OutArray;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement