public void SetData(byte[] data, string filename) { PalImage = GrfEditor.Library.Properties.Resources.image_error; mName = filename; mPalette = new RoPalette(data); UpdateChart(); }
protected override bool ReadInternal() { ImagesPal = new List<RoSpriteImagePal>(); ImagesRgba = new List<RoSpriteImageRgba>(); Palette = new RoPalette(); MagicHead = Reader.ReadChars(2); if (MagicHead[0] != 0x53 || MagicHead[1] != 0x50) { // Invalid header return false; } Version = new GenericFileFormatVersion(Reader); if (Version.Major > 2) { // Unsupported version return false; } int imgPalCount = Reader.ReadUInt16(); int imgRgbaCount = 0; if (Version >= 0x201) { imgRgbaCount = Reader.ReadUInt16(); } // Images - Palette \\ RoSpriteImagePal imgPal; for (int i = 0; i < imgPalCount; i++) { imgPal = new RoSpriteImagePal() { Width = Reader.ReadUInt16(), Height = Reader.ReadUInt16() }; if (Version >= 0x201) { imgPal.Size = Reader.ReadUInt16(); } else { imgPal.Size = (ushort)(imgPal.Width * imgPal.Height); } imgPal.Data = Reader.ReadBytes(imgPal.Size); ImagesPal.Add(imgPal); } // Images - RGBA \\ RoSpriteImageRgba imgRgba; for (int i = 0; i < imgRgbaCount; i++) { imgRgba = new RoSpriteImageRgba() { Width = Reader.ReadUInt16(), Height = Reader.ReadUInt16() }; int size = (imgRgba.Width * imgRgba.Height * 4); imgRgba.Data = Reader.ReadBytes(size); ImagesRgba.Add(imgRgba); } // Palette \\ Reader.BaseStream.Position = (Reader.BaseStream.Length - (4 * RoPalette.ColorCount)); Palette.Read(Reader.BaseStream); Flush(); return true; }
protected override bool ReadInternal() { ImagesPal = new List <DrawableRoSpriteImagePal>(); ImagesRgba = new List <DrawableRoSpriteImageRgba>(); Palette = new RoPalette(); MagicHead = Reader.ReadChars(2); if (MagicHead[0] != 0x53 || MagicHead[1] != 0x50) { // Invalid header return(false); } Version = new GenericFileFormatVersion(Reader); if (Version.Major > 2) { // Unsupported version return(false); } int imgPalCount = Reader.ReadUInt16(); int imgRgbaCount = 0; if (Version >= 0x201) { imgRgbaCount = Reader.ReadUInt16(); } // Images - Palette \\ DrawableRoSpriteImagePal imgPal; for (int i = 0; i < imgPalCount; i++) { imgPal = new DrawableRoSpriteImagePal() { Width = Reader.ReadUInt16(), Height = Reader.ReadUInt16() }; if (Version >= 0x201) { imgPal.Size = Reader.ReadUInt16(); } else { imgPal.Size = (ushort)(imgPal.Width * imgPal.Height); } imgPal.Data = Reader.ReadBytes(imgPal.Size); ImagesPal.Add(imgPal); } // Images - RGBA \\ DrawableRoSpriteImageRgba imgRgba; for (int i = 0; i < imgRgbaCount; i++) { imgRgba = new DrawableRoSpriteImageRgba() { Width = Reader.ReadUInt16(), Height = Reader.ReadUInt16() }; int size = (imgRgba.Width * imgRgba.Height * 4); imgRgba.Data = Reader.ReadBytes(size); ImagesRgba.Add(imgRgba); } // Palette \\ Reader.BaseStream.Position = (Reader.BaseStream.Length - (4 * RoPalette.ColorCount)); Palette.Read(Reader.BaseStream); Flush(); return(true); }