using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using System.IO; using FSO.Files.Utils; namespace FSO.Files.Formats.IFF.Chunks { public static class SPR2FrameEncoder { public delegate Color[] QuantizerFunction(SPR2Frame frame, out byte[] bytes); public static QuantizerFunction QuantizeFrame; public static void WriteFrame(SPR2Frame frame, IoWriter output) { var bytes = frame.PalData; var col = frame.PixelData; var zs = frame.ZBufferData; int index = 0; int blankLines = 0; for (int y=0; y dataBuf = new List(); int rlecount = 0; bool anySolid = false; var scanStream = new MemoryStream(); var scanOut = IoWriter.FromStream(scanStream, ByteOrder.LITTLE_ENDIAN); for (int x=0; x 0) { //add transparent lines before our new command output.WriteUInt16((ushort)((0x4<<13) | blankLines)); blankLines = 0; } output.WriteUInt16((ushort)(scanData.Length+2)); output.WriteBytes(scanData); } } if (blankLines > 0) { //add transparent lines before our new command output.WriteUInt16((ushort)((0x4 << 13) | blankLines)); blankLines = 0; } output.WriteUInt16((ushort)(0x5<<13)); return; } private static byte getCmd(byte col, byte a, byte z) { if (a == 0) return 0x03; //transparent fill else if (a < 255) return 0x02; // col,a,z else if (z > 0) return 0x01; // col,z else return 0x06; // col } } }