示例#1
0
        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);
        }
示例#2
0
 public void SaveAsPng(string saveFile, bool tiled = true)
 {
     ImageUtil.SaveAsPng(
         file: saveFile,
         new ImageInfo(Pixels, RawPalette.To32bitColors(Palette), Width, Height),
         tiled: tiled
         );
 }
示例#3
0
            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));
            }
示例#4
0
 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
         );
 }
示例#5
0
        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));
        }
示例#6
0
        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,
            });
        }
示例#7
0
        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));
        }
示例#8
0
        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);
        }
示例#9
0
        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),
            });
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }