public void WriteTo(BinaryWriter bw) { var header = new Header { TotalLength = Header.Length + PaletteDataLength + (Width * Height) + PaddingLength, Unknown1 = 0x_77_77_77_77, Width = Width, Height = Height, Unknown2 = 1 }; header.WriteTo(bw); var posBeforePal = bw.BaseStream.Position; bw.Write(RawPalette.Compress(Palette)); var posAfterPal = bw.BaseStream.Position; int palLen = (int)(posAfterPal - posBeforePal); if (palLen < PaletteDataLength) { bw.Pad(PaletteDataLength - palLen); } bw.Write(Pixels); bw.Pad(PaddingLength); }
public void SaveAsPng(string saveFile, bool tiled = true) { ImageUtil.SaveAsPng( file: saveFile, new ImageInfo(Pixels, RawPalette.To32bitColors(Palette), Width, Height), tiled: tiled ); }
public PLTT(BinaryReader br) { var initOffset = br.BaseStream.Position; var header = new Header(br); br.BaseStream.Position = initOffset + 8 + header.DataOffset; Palette = RawPalette.Decompress(br.ReadBytes(header.DataLength)); }
public void SaveAsPng(NCER ncer, string saveFile, bool debug = false, bool tiled = false) { ImageUtil.SaveAsPng( file: saveFile, bank: ncer.CellBanks.Banks[0], blockSize: ncer.CellBanks.BlockSize, new ImageInfo(Pixels, RawPalette.To32bitColors(Palette), Width, Height), debug: debug, tiled: tiled ); }
public void WriteTo(BinaryWriter bw) { var initOffset = bw.BaseStream.Position; bw.BaseStream.Position = initOffset + HeaderInstance.TextureDataOffset; var compressedPixels = RawChar.Compress(PixelMap); bw.Write(compressedPixels); bw.BaseStream.Position = initOffset + HeaderInstance.PaletteDataOffset; bw.Write(RawPalette.Compress(Palette1)); bw.Write(RawPalette.Compress(Palette2)); }
public static SCBG LoadPng(string file, bool tiled = true) { var imageInfo = ImageUtil.LoadPng(file, tiled); return(new SCBG { Width = (ushort)imageInfo.Width, Height = (ushort)imageInfo.Height, Palette = RawPalette.From32bitColors(imageInfo.Palette), Pixels = imageInfo.Pixels, }); }
public TEX0(BinaryReader br) { var initOffset = br.BaseStream.Position; HeaderInstance = new Header(br); br.BaseStream.Position = initOffset + HeaderInstance.TextureDataOffset; PixelMap = RawChar.Decompress(br.ReadBytes(HeaderInstance.TextureDataLength)); br.BaseStream.Position = initOffset + HeaderInstance.PaletteDataOffset; var palLen = HeaderInstance.PaletteDataLength / 2; Palette1 = RawPalette.Decompress(br.ReadBytes(palLen)); Palette2 = RawPalette.Decompress(br.ReadBytes(palLen)); }
public static STL Load(BinaryReader br) { var header = new Header(br); var stl = new STL { Width = header.Width, Height = header.Height, Palette = RawPalette.Decompress(br.ReadBytes(PaletteDataLength)), Pixels = br.ReadBytes(header.Width * header.Height) }; br.Skip(PaddingLength); return(stl); }
public static STL LoadPng(NCER ncer, string pngFile, bool tiled = false) { var imageInfo = ImageUtil.LoadPng( file: pngFile, bank: ncer.CellBanks.Banks[0], blockSize: ncer.CellBanks.BlockSize, tiled: tiled ); return(new STL() { Width = imageInfo.Width, Height = imageInfo.Height, Pixels = imageInfo.Pixels, Palette = RawPalette.From32bitColors(imageInfo.Palette), }); }
public void WriteTo(BinaryWriter bw) { bw.WriteMagicNumber(MagicNumber); bw.Write(Width); bw.Write(Height); var posBeforePal = bw.BaseStream.Position; bw.Write(RawPalette.Compress(Palette)); var posAfterPal = bw.BaseStream.Position; int palLen = (int)(posAfterPal - posBeforePal); if (palLen < PaletteDataLength) { bw.Pad(PaletteDataLength - palLen); } bw.Write(Pixels); }
public static SCBG Load(BinaryReader br) { var scbg = new SCBG(); var magicNumber = br.ReadMagicNumber(); if (magicNumber != MagicNumber) { throw new InvalidDataException($"Unexpected magic number '{magicNumber}'. (expected: {MagicNumber})"); } scbg.Width = br.ReadUInt16(); scbg.Height = br.ReadUInt16(); scbg.Palette = RawPalette.Decompress(br.ReadBytes(PaletteDataLength)); scbg.Pixels = br.ReadBytes(scbg.Width * scbg.Height); return(scbg); }