private void LoadPaletteABGR1555(IwSerialise serialise) { this.data = new byte[this.height * this.pitch]; serialise.Serialise(ref this.data); this.palette = new Color[256]; for (int i = 0; i < this.palette.Length; ++i) { ushort r = 0; serialise.UInt16(ref r); this.palette[i] = Color.FromArgb( (byte)(((r >> 10) & 0x1F) << 3), (byte)(((r >> 5) & 0x1F) << 3), (byte)(((r >> 0) & 0x1F) << 3)); } byte[] d = new byte[this.height * this.width * 3]; int j = 0; for (int y = 0; y < this.height; ++y) { for (int x = 0; x < this.width; ++x) { d[j] = this.palette[this.data[x + y * this.pitch]].R; ++j; d[j] = this.palette[this.data[x + y * this.pitch]].G; ++j; d[j] = this.palette[this.data[x + y * this.pitch]].B; ++j; } } this.data = d; }
private void Load256ColourPalettised(IwSerialise serialise) { this.data = new byte[this.height * this.pitch]; serialise.Serialise(ref this.data); this.palette = new Color[256]; for (int i = 0; i < this.palette.Length; ++i) { byte r = 0; byte g = 0; byte b = 0; serialise.UInt8(ref r); serialise.UInt8(ref g); serialise.UInt8(ref b); this.palette[i] = Color.FromArgb(r, g, b); } byte[] d = new byte[this.height * this.width * 3]; int j = 0; for (int y = 0; y < this.height; ++y) { for (int x = 0; x < this.width; ++x) { d[j] = this.palette[this.data[x + y * this.pitch]].R; ++j; d[j] = this.palette[this.data[x + y * this.pitch]].G; ++j; d[j] = this.palette[this.data[x + y * this.pitch]].B; ++j; } } this.data = d; ////using (var b = new Bitmap(width,height)) ////{ //// for (int i = 0; i < height;++i) //// for (int x = 0; x < width; ++x) //// { //// b.SetPixel(x,i,palette[data[x+i*pitch]]); //// } //// b.Save("res.bmp"); ////} }
private void LoadABGR1555(IwSerialise serialise) { var d = new ushort[this.height * this.pitch / 2]; serialise.Serialise(ref d); this.data = new byte[this.width * this.height * 3]; int dst = 0, src = 0; for (int y = 0; y < this.height; ++y) { for (int x = 0; x < this.width; ++x) { var r = d[src]; ++src; this.data[dst] = (byte)(((r >> 0) & 0x1F) << 3); ++dst; this.data[dst] = (byte)(((r >> 5) & 0x1F) << 3); ++dst; this.data[dst] = (byte)(((r >> 10) & 0x1F) << 3); ++dst; } } }
private void LoadUncompressed(IwSerialise serialise) { this.data = new byte[this.height * this.pitch]; serialise.Serialise(ref this.data); }