public override void Read(string fileIn) { byte[] data = File.ReadAllBytes(fileIn); data = Encryption.Image.Decrypt(data); int width = BitConverter.ToInt16(data, 8); int height = BitConverter.ToInt16(data, 0x0C); int num_colors = BitConverter.ToInt16(data, 0xE); int img_pos = num_colors * 2 + 0x20; // Get image byte[] tiles = new byte[width * height]; Array.Copy(data, img_pos, tiles, 0, tiles.Length); ColorFormat format = ColorFormat.colors256; if (num_colors == 0x10) { format = ColorFormat.colors16; width *= 2; } Set_Tiles(tiles, width, height, format, TileForm.Lineal, false); // Get palette byte[] pal = new byte[num_colors * 2]; Array.Copy(data, 0x20, pal, 0, pal.Length); Color[] colors = Actions.BGR555ToColor(pal); RawPalette palette = new RawPalette(new Color[][] { colors }, false, format); pluginHost.Set_Palette(palette); pluginHost.Set_Image(this); }
private void btnImport_Click(object sender, EventArgs e) { OpenFileDialog o = new OpenFileDialog(); o.CheckFileExists = true; o.Filter = "All supported formats|*.pal;*.aco;*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon|" + "Windows Palette (*.pal)|*.pal|" + "Adobe COlor (*.aco)|*.aco|" + "Palette from image|*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon"; if (o.ShowDialog() != DialogResult.OK) { return; } string ext = Path.GetExtension(o.FileName).ToLower(); if (string.IsNullOrEmpty(ext) || ext.Length == 0) { MessageBox.Show("File without extension... Aborting"); return; } if (ext.Contains(".")) { ext = ext.Substring(ext.LastIndexOf(".") + 1); } Console.WriteLine("File extension:" + ext); PaletteBase newpal; if (ext == "pal") { newpal = new Formats.PaletteWin(o.FileName); } else if (ext == "aco") { newpal = new Formats.ACO(o.FileName); } else { byte[] tiles; Color[] newcol; Actions.Indexed_Image((Bitmap)Image.FromFile(o.FileName), palette.Depth, out tiles, out newcol); newpal = new RawPalette(newcol, palette.CanEdit, palette.Depth); } if (newpal != null) { palette.Set_Palette(newpal); } // Write the file Write_File(); o.Dispose(); o = null; }
private void btnImport_Click(object sender, EventArgs e) { SaveFileDialog o = new SaveFileDialog(); o.CheckFileExists = true; o.Filter = "All supported formats|*.pal;*.aco;*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon|" + "Windows Palette (*.pal)|*.pal|" + "Adobe COlor (*.aco)|*.aco|" + "Palette from image|*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon"; if (o.ShowDialog() != DialogResult.OK) { return; } string ext = Path.GetExtension(o.FileName).ToLower(); PaletteBase newpal; if (ext == "pal") { newpal = new Formats.PaletteWin(o.FileName); } else if (ext == "aco") { newpal = new Formats.ACO(o.FileName); } else { byte[] tiles; Color[] newcol; Actions.Indexed_Image((Bitmap)Image.FromFile(o.FileName), palette.Depth, out tiles, out newcol); newpal = new RawPalette(newcol, palette.CanEdit, palette.Depth); } if (newpal != null) { palette.Set_Palette(newpal); } // Write the file Write_File(); o.Dispose(); o = null; }
public Format Read2(sFile file) { string ext = ""; if (file.size >= 4) { using (BinaryReader br = new BinaryReader(File.OpenRead(file.path))) { ext = new String(Encoding.ASCII.GetChars(br.ReadBytes(4))); br.Close(); } } // Palette if (file.name.ToUpper().EndsWith(".NTFP") || file.name.ToUpper().EndsWith(".PLT")) { RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name); pluginHost.Set_Palette(palette); return Format.Palette; } else if (ext == "RLCN") { PaletteBase palette = new NCLR(file.path, file.id, file.name); pluginHost.Set_Palette(palette); return Format.Palette; } else if (ext == "NCCL") { NCCL palette = new NCCL(file.path, file.id, file.name); pluginHost.Set_Palette(palette); return Format.Palette; } else if (file.name.ToUpper().EndsWith(".NBFP")) { RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name); pluginHost.Set_Palette(palette); return Format.Palette; } else if (file.name.ToUpper().EndsWith(".NCL.L") && ext[0] != '\x10') { RawPalette palette = new RawPalette(file.path, file.id, true, 0, -1, file.name); pluginHost.Set_Palette(palette); return Format.Palette; } // Tile ColorFormat depth = ColorFormat.colors256; if (pluginHost.Get_Palette().Loaded) depth = pluginHost.Get_Palette().Depth; if (file.name.ToUpper().EndsWith(".NTFT")) { RawImage image = new RawImage(file.path, file.id, TileForm.Lineal, depth, true, 0, -1, file.name); pluginHost.Set_Image(image); return Format.Tile; } else if (ext == "RGCN" || ext == "RBCN") { NCGR ncgr = new NCGR(file.path, file.id, file.name); pluginHost.Set_Image(ncgr); return Format.Tile; } else if (ext == "NCCG") { NCCG image = new NCCG(file.path, file.id, file.name); pluginHost.Set_Image(image); return Format.Tile; } else if (file.name.ToUpper().EndsWith(".NBFC") || file.name.ToUpper().EndsWith(".CHAR")) { RawImage image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name); pluginHost.Set_Image(image); return Format.Tile; } else if (file.name.ToUpper().EndsWith(".NCG.L") && ext[0] != '\x10') { RawImage image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name); pluginHost.Set_Image(image); return Format.Tile; } // Map if (file.name.ToUpper().EndsWith(".NBFS")) { RawMap map = new RawMap(file.path, file.id, 0, -1, true, file.name); pluginHost.Set_Map(map); return Format.Map; } else if (ext == "RCSN") { NSCR nscr = new NSCR(file.path, file.id, file.name); pluginHost.Set_Map(nscr); return Format.Map; } else if (ext == "NCSC") { NCSC map = new NCSC(file.path, file.id, file.name); pluginHost.Set_Map(map); return Format.Map; } else if (file.name.ToUpper().EndsWith(".NSC.L") && ext[0] != '\x10') { RawMap map = new RawMap(file.path, file.id, 0, -1, true, file.name); pluginHost.Set_Map(map); return Format.Map; } // Sprite if (ext == "NCOB") { NCOB sprite = new NCOB(file.path, file.id, file.name); pluginHost.Set_Sprite(sprite); pluginHost.Set_Image(sprite.Image); return Format.Cell; } else if (ext == "RECN") { NCER ncer = new NCER(file.path, file.id, file.name); pluginHost.Set_Sprite(ncer); return Format.Cell; } // Animation if (ext == "RNAN") { nanr = new NANR(pluginHost, file.path, file.id); return Format.Animation; } return Format.Unknown; }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Header char[] type = br.ReadChars(4); // "STD " uint unknown_header = br.ReadUInt32(); ushort clrformat = br.ReadUInt16(); ColorFormat format = ColorFormat.colors256; if (clrformat == 0) format = ColorFormat.colors16; br.BaseStream.Position = 0x10; // Unknown values // Palette ushort unknown_pal = br.ReadUInt16(); ushort num_colors = br.ReadUInt16(); Color[] colors = Actions.BGR555ToColor(br.ReadBytes(num_colors * 2)); PaletteBase palette = new RawPalette(new Color[][] { colors }, false, format); // Map int tile_width = br.ReadUInt16() * 8; int tile_height = br.ReadUInt16() * 8; int tile_size = tile_width * tile_height; if (tile_height != tile_width) System.Windows.Forms.MessageBox.Show("Different tile size; height != width"); int width = br.ReadUInt16() * tile_width; int height = br.ReadUInt16() * tile_height; uint unknown2_map = br.ReadUInt32(); // Padding ? NTFS[] map = new NTFS[width * height / tile_size]; for (int i = 0; i < map.Length; i++) { map[i] = new NTFS(); uint mapv = br.ReadUInt32(); map[i].nTile = (ushort)(mapv & 0xFFFFFF); map[i].nTile /= (ushort)(tile_size / 0x40); map[i].nPalette = (byte)(mapv >> 28); } Set_Map(map, false, width, height); // Image if (clrformat == 2) format = ColorFormat.A3I5; else if (clrformat == 3) format = ColorFormat.A5I3; else if (clrformat != 0 && clrformat != 1) System.Windows.Forms.MessageBox.Show("ClrFormat: " + clrformat.ToString()); byte[] tiles = br.ReadBytes((int)(br.BaseStream.Length - br.BaseStream.Position)); ImageBase image = new RawImage(tiles, TileForm.Horizontal, format, width, height, false); image.TileSize = tile_width; br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Map(this); }
private void numImg_ValueChanged(object sender, EventArgs e) { int i = (int)numImg.Value; BinaryReader br = new BinaryReader(File.OpenRead(gbcs)); br.BaseStream.Position = infos[i].offset; char[] header = br.ReadChars(4); ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); Color[][] palette = new Color[1][] { Actions.BGR555ToColor(br.ReadBytes(0x200)) }; byte[] tiles = br.ReadBytes((int)(infos[i].size - 0x208)); br.Close(); RawPalette pal = new RawPalette(palette, false, ColorFormat.colors256); RawImage img = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, (int)width, (int)height, false); this.Controls.Remove(imgControl); this.imgControl = new ImageControl(pluginHost, img, pal); this.Controls.Add(imgControl); }
private void btnExtract_Click(object sender, EventArgs e) { FolderBrowserDialog o = new FolderBrowserDialog(); o.Description = "Select the folder to extract the images"; o.ShowNewFolderButton = true; if (o.ShowDialog() != DialogResult.OK) return; string folderOut = o.SelectedPath + Path.DirectorySeparatorChar; this.Cursor = Cursors.WaitCursor; BinaryReader br = new BinaryReader(File.OpenRead(gbcs)); for (int i = 0; i < infos.Length; i++) { br.BaseStream.Position = infos[i].offset; char[] header = br.ReadChars(4); ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); Color[][] palette = new Color[1][] { Actions.BGR555ToColor(br.ReadBytes(0x200)) }; byte[] tiles = br.ReadBytes((int)(infos[i].size - 0x208)); RawPalette pal = new RawPalette(palette, false, ColorFormat.colors256); RawImage img = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, (int)width, (int)height, false); img.Get_Image(pal).Save(folderOut + "Image" + i.ToString() + ".png"); } br.Close(); this.Cursor = Cursors.Default; }
public override void Read(string file) { // It's compressed pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List<sFile>) dec_file = dec_folder.files[0].path; else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length); ; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); // Bank info Ekona.Images.Bank[] banks = new Ekona.Images.Bank[br.ReadUInt32()]; uint num_cells = br.ReadUInt32(); uint unknown1 = br.ReadUInt32(); for (int i = 0; i < banks.Length; i++) { uint unk = br.ReadUInt16(); banks[i].oams = new OAM[br.ReadUInt16()]; } // Read cell information for (int i = 0; i < banks.Length; i++) { for (int j = 0; j < banks[i].oams.Length; j++) { banks[i].oams[j].obj1.xOffset = br.ReadInt16(); banks[i].oams[j].obj0.yOffset = br.ReadInt16(); uint size_b = br.ReadUInt32(); byte b1 = (byte)(size_b & 0x03); byte b2 = (byte)((size_b & 0x0C) >> 2); System.Drawing.Size size = Actions.Get_OAMSize(b1, b2); banks[i].oams[j].width = (ushort)size.Width; banks[i].oams[j].height = (ushort)size.Height; banks[i].oams[j].obj2.tileOffset = br.ReadUInt32(); banks[i].oams[j].obj2.index_palette = 0; banks[i].oams[j].num_cell = (ushort)j; } } Set_Banks(banks, 2, false); pluginHost.Set_Sprite(this); // Palette PaletteBase palette; int palette_length = (int)(br.BaseStream.Length - br.BaseStream.Position); Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes(palette_length)); br.Close(); palette = new RawPalette(colors, false, (palette_length > 0x20) ? ColorFormat.colors256 : ColorFormat.colors16); pluginHost.Set_Palette(palette); }
private void btnImport_Click(object sender, EventArgs e) { OpenFileDialog o = new OpenFileDialog(); o.CheckFileExists = true; o.Filter = "All supported formats|*.pal;*.aco;*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon|" + "Windows Palette (*.pal)|*.pal|" + "Adobe COlor (*.aco)|*.aco|" + "Palette from image|*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon"; if (o.ShowDialog() != DialogResult.OK) return; string ext = Path.GetExtension(o.FileName).ToLower(); if (string.IsNullOrEmpty(ext) || ext.Length == 0) { MessageBox.Show("File without extension... Aborting"); return; } if (ext.Contains(".")) ext = ext.Substring(ext.LastIndexOf(".") + 1); Console.WriteLine("File extension:" + ext); PaletteBase newpal; if (ext == "pal") newpal = new Formats.PaletteWin(o.FileName); else if (ext == "aco") newpal = new Formats.ACO(o.FileName); else { byte[] tiles; Color[] newcol; Actions.Indexed_Image((Bitmap)Image.FromFile(o.FileName), palette.Depth, out tiles, out newcol); newpal = new RawPalette(newcol, palette.CanEdit, palette.Depth); } if (newpal != null) palette.Set_Palette(newpal); // Write the file Write_File(); o.Dispose(); o = null; }
private void button1_Click(object sender, EventArgs e) { int num_tex = listTextures.SelectedIndex; int num_pal = listPalettes.SelectedIndex; sBTX0.Texture.TextInfo texInfo = (sBTX0.Texture.TextInfo)btx0.texture.texInfo.infoBlock.infoData[num_tex]; sBTX0.Texture.PalInfo palInfo = (sBTX0.Texture.PalInfo)btx0.texture.palInfo.infoBlock.infoData[num_pal]; // Get palette data BinaryReader br = new BinaryReader(File.OpenRead(btx0.file)); br.BaseStream.Position = btx0.header.offset[0] + btx0.texture.header.paletteData_offset; br.BaseStream.Position += palInfo.palette_offset * 8; Byte[] palette_data = br.ReadBytes((int)PaletteSize[texInfo.format]); Color[] palette = Actions.BGR555ToColor(palette_data); br.Close(); SaveFileDialog o = new SaveFileDialog(); o.AddExtension = true; o.CheckPathExists = true; o.DefaultExt = ".pal"; o.Filter = "Windows Palette for Gimp 2.8 (*.pal)|*.pal|" + "Windows Palette (*.pal)|*.pal|" + "Portable Network Graphics (*.png)|*.png|" + "Adobe COlor (*.aco)|*.aco"; o.OverwritePrompt = true; if (o.ShowDialog() != DialogResult.OK) return; if (o.FilterIndex == 3) { RawPalette p = new RawPalette(palette, false, ColorFormat.colors256); p.Get_Image(0).Save(o.FileName, System.Drawing.Imaging.ImageFormat.Png); } else if (o.FilterIndex == 1 || o.FilterIndex == 2) { Ekona.Images.Formats.PaletteWin palwin = new Ekona.Images.Formats.PaletteWin(palette); if (o.FilterIndex == 1) palwin.Gimp_Error = true; palwin.Write(o.FileName); } else if (o.FilterIndex == 4) { Ekona.Images.Formats.ACO palaco = new Ekona.Images.Formats.ACO(palette); palaco.Write(o.FileName); } o.Dispose(); }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); info = new SIR0_Info(); PaletteBase palette; ImageBase image; Ekona.Images.Bank bank; // Read header char[] file_id = br.ReadChars(4); uint offset1 = br.ReadUInt32(); uint offset2 = br.ReadUInt32(); uint unknown = br.ReadUInt32(); String name = ""; do { byte c = br.ReadByte(); if (c == 0xAA) c = 0x00; name += (char)c; } while (name[name.Length - 1] != '\x0'); // Read info section // Info 1 br.BaseStream.Position = offset1; info.info1 = new SIR0_Info.Info1(); info.info1.constant = br.ReadUInt32(); info.info1.reserved = br.ReadBytes(0x3C); info.info1.info3_offset = br.ReadUInt32(); info.info1.reserved2 = br.ReadBytes((int)(offset2 - offset1)); // Info 2 br.BaseStream.Position = offset2; info.info2 = new SIR0_Info.Info2(); info.info2.unknown = br.ReadBytes(0x10); // Info 3 br.BaseStream.Position = info.info1.info3_offset; info.info3 = new SIR0_Info.Info3(); info.info3.tile_size = br.ReadUInt32(); info.info3.unknown1 = br.ReadUInt32(); info.info3.unknown2 = br.ReadUInt32(); info.info3.unknown3 = br.ReadUInt32(); info.info3.unknown4 = br.ReadUInt32(); info.info3.palette_offset = br.ReadUInt32(); info.info3.tile_offset = br.ReadUInt32(); info.info3.cell_offset = br.ReadUInt32(); info.info3.unknown5 = br.ReadUInt32(); info.info3.reserved = br.ReadBytes(0x3C); // Read palette br.BaseStream.Position = info.info3.palette_offset; Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes(0x200)); palette = new RawPalette(colors, false, ColorFormat.colors256, ""); // Read tiles br.BaseStream.Position = info.info3.tile_offset; byte[] tiles = new byte[info.info3.tile_size]; tiles = br.ReadBytes((int)info.info3.tile_size); image = new RawImage(tiles, TileForm.Lineal, ColorFormat.colors256, 0x40, (int)(info.info3.tile_size / 0x40), false, ""); // Read cell info uint bank_size; if (info.info3.unknown5 != 0x00) bank_size = info.info3.unknown5 - info.info3.cell_offset - 0x06; else bank_size = info.info1.info3_offset - info.info3.cell_offset - 0x06; br.BaseStream.Position = info.info3.cell_offset; bank = new Ekona.Images.Bank(); bank.oams = new OAM[bank_size / 0x0A]; for (int i = 0; i < bank.oams.Length; i++) { bank.oams[i].width = br.ReadUInt16(); bank.oams[i].height = br.ReadUInt16(); bank.oams[i].obj1.xOffset = br.ReadUInt16() - 0x80; bank.oams[i].obj0.yOffset = br.ReadUInt16() - 0x80; bank.oams[i].obj2.tileOffset = (uint)(br.ReadUInt16() / 0x20); bank.oams[i].num_cell = (ushort)i; } Set_Banks(new Ekona.Images.Bank[] { bank }, 0, false); br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Sprite(this); }
public void Read(sFile file) { if (file.id == 0xE7 || file.id == 0xEA) { RawPalette palette = new RawPalette(file.path, file.id, false, 0, -1); pluginHost.Set_Palette(palette); } else if (file.id == 0xE6 || file.id == 0xE9) { RawImage image = new RawImage(file.path, file.id, TileForm.Lineal, ColorFormat.colors16, false, 0, -1); image.Width = 0x80; image.Height = 0x200; pluginHost.Set_Image(image); } }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); cgx = new sCGx(); cgx.type = br.ReadChars(4); // CG4 cgx.unknown1 = br.ReadUInt32(); cgx.unknown2 = br.ReadUInt32(); cgx.unknown3 = br.ReadUInt32(); // Usually 0 cgx.unknown4 = br.ReadUInt32(); // Usually 0 cgx.size_tiles = br.ReadUInt32(); cgx.unknown5 = br.ReadUInt32(); cgx.num_tiles = br.ReadUInt32(); cgx.palColors = br.ReadUInt32(); cgx.tileOffset = br.ReadUInt32(); cgx.palOffset = br.ReadUInt32(); cgx.unknonwnOffset = br.ReadUInt32(); // If 0, it doesn't exist // Read tiles br.BaseStream.Position = cgx.tileOffset; int tile_size = (depth == ColorFormat.colors16 ? 0x20 : 0x40); Byte[] tiles = br.ReadBytes((int)cgx.num_tiles * tile_size); Set_Tiles(tiles, WIDTH, (int)(tiles.Length / WIDTH), depth, TileForm.Horizontal, false); if (depth == Ekona.Images.ColorFormat.colors16) Height *= 2; // Read palette br.BaseStream.Position = cgx.palOffset; Color[][] colors; if (depth == Ekona.Images.ColorFormat.colors16) { colors = new Color[cgx.palColors / 0x10][]; for (int i = 0; i < colors.Length; i++) colors[i] = Actions.BGR555ToColor(br.ReadBytes(32)); } else { colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)cgx.palColors * 2)); } PaletteBase palette = new RawPalette(colors, false, depth); br.BaseStream.Position = cgx.unknonwnOffset; cgx.unknown = br.ReadBytes((int)(br.BaseStream.Length - br.BaseStream.Position)); br.Close(); }
public System.Windows.Forms.Control Show_Info(sFile file) { if (file.name.EndsWith(".acl")) { PaletteBase palette = new RawPalette(file.path, file.id, true, 0, -1, file.name); pluginHost.Set_Palette(palette); return new PaletteControl(pluginHost); } if (file.name.EndsWith(".acg")) { ColorFormat depth = (pluginHost.Get_Palette().Loaded ? pluginHost.Get_Palette().Depth : ColorFormat.colors256); ImageBase image = new RawImage(file.path, file.id, TileForm.Horizontal, depth, true, 0, -1, file.name); pluginHost.Set_Image(image); return new ImageControl(pluginHost, false); } if (file.name.EndsWith(".asc")) { MapBase map = new Naruto_ASC(file); pluginHost.Set_Map(map); return new ImageControl(pluginHost, true); } return new System.Windows.Forms.Control(); }
private System.Windows.Forms.Control ShowImage(sFile file) { #region Palette BinaryReader br = new BinaryReader(File.OpenRead(file.path)); br.ReadUInt32(); // 4 Bytes Stupid uint num_colors = 256; byte[] pal = br.ReadBytes((int)num_colors * 2); Color[] colors = Actions.BGR555ToColor(pal); PaletteBase palette = new RawPalette(colors, false, ColorFormat.colors256, file.name); br.ReadUInt32(); // 4 Bytes Stupid #endregion #region Map NTFS[] map_info = new NTFS[1024]; for (int i = 0; i < 1024; i++) { ushort value = br.ReadUInt16(); map_info[i] = Actions.MapInfo(value); } MapBase map = new RawMap(map_info, 256, 192, false, file.name); #endregion #region Tiles uint size_section = (uint)(br.ReadUInt32() * 64); Console.WriteLine("Size section: " + size_section.ToString("x")); byte[] readsize = br.ReadBytes((int)size_section); ImageBase image = new RawImage(readsize, TileForm.Horizontal, ColorFormat.colors256, 256, 192, false, file.name); #endregion br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Map(map); return new ImageControl(pluginHost, image, palette, map); }
private void btnExtract_Click(object sender, EventArgs e) { string folder; FolderBrowserDialog o = new FolderBrowserDialog(); o.Description = "Select the folder where you want\nto extract all the images."; o.ShowNewFolderButton = true; if (o.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; folder = o.SelectedPath + Path.DirectorySeparatorChar; SpriteBase sprite = pluginHost.Get_Sprite(); this.Cursor = Cursors.WaitCursor; for (int i = 0; i < infos.Length; i++) { int offset = (int)infos[i].offset; int size = (int)infos[i].size; TileForm form = (images.EndsWith("Tex.dat") ? TileForm.Lineal : TileForm.Horizontal); RawImage image = new RawImage(images, -1, form, ColorFormat.colors256, false, offset + 0x220, size - 0x220); RawPalette palette = new RawPalette(images, -1, false, offset + 0x20, 0x200); sprite.Get_Image(image, palette, 0, 512, 256, false, false, false, true, true).Save(folder + "Image" + i.ToString() + ".png"); } this.Cursor = Cursors.Default; }
private void numImg_ValueChanged(object sender, EventArgs e) { int offset = (int)infos[(int)numImg.Value].offset; int size = (int)infos[(int)numImg.Value].size; TileForm form = (images.EndsWith("Tex.dat") ? TileForm.Lineal : TileForm.Horizontal); RawImage image = new RawImage(images, -1, form, ColorFormat.colors256, false, offset + 0x220, size - 0x220); pluginHost.Set_Image(image); RawPalette palette = new RawPalette(images, -1, false, offset + 0x20, 0x200); pluginHost.Set_Palette(palette); this.Controls.Remove(spriteControl1); spriteControl1 = new SpriteControl(pluginHost); this.Controls.Add(spriteControl1); }
public System.Windows.Forms.Control Show_Info(sFile file) { if ((file.id >= 0x12C && file.id <= 0x165) || (file.id >= 0x65D && file.id <= 0x68A) || file.id == 0x16B || file.id == 0x16C) return new TextControl(pluginHost, file.path); if ((file.id >= 0x1E4 && file.id <= 0x1F4) || (file.id >= 0x1F7 && file.id <= 0x2FC)) { string[] p = new String[] { file.path, "Sounds.Main", file.name + ".adx", "" }; return (System.Windows.Forms.Control)pluginHost.Call_Plugin(p, file.id, 1); } if (file.id >= 0x01 && file.id <= 0x1E3) if (file.size == 512 || file.size == 128 || file.size == 32) { RawPalette palette = new RawPalette(file.path, file.id, false, 0, -1, file.name); pluginHost.Set_Palette(palette); return new PaletteControl(pluginHost); } else return new Images(pluginHost, file.path, file.id).Get_Control(); return new System.Windows.Forms.Control(); }
private void UpdateTexture(int num_tex, int num_pal) { sBTX0.Texture.TextInfo texInfo = (sBTX0.Texture.TextInfo)btx0.texture.texInfo.infoBlock.infoData[num_tex]; sBTX0.Texture.PalInfo palInfo = (sBTX0.Texture.PalInfo)btx0.texture.palInfo.infoBlock.infoData[num_pal]; // Get texture data BinaryReader br = new BinaryReader(File.OpenRead(btx0.file)); if (texInfo.format != 5) br.BaseStream.Position = texInfo.tex_offset * 8 + btx0.header.offset[0] + btx0.texture.header.textData_offset; else br.BaseStream.Position = btx0.header.offset[0] + btx0.texture.header.textCompressedData_offset + texInfo.tex_offset * 8; Byte[] tile_data = br.ReadBytes((int)(texInfo.width * texInfo.height * texInfo.depth / 8)); // Get palette data br.BaseStream.Position = btx0.header.offset[0] + btx0.texture.header.paletteData_offset; br.BaseStream.Position += palInfo.palette_offset * 8; Byte[] palette_data = br.ReadBytes((int)PaletteSize[texInfo.format]); Color[] palette = Actions.BGR555ToColor(palette_data); br.Close(); picTex.Image = Draw_Texture(tile_data, texInfo, palette); Clipboard.SetImage(picTex.Image); PaletteBase p = new RawPalette(new Color[][] { palette }, false, ColorFormat.colors256); picPalette.Image = p.Get_Image(0); pluginHost.Set_Palette(p); Info(num_tex, num_pal); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); char[] type = br.ReadChars(4); uint offset1 = br.ReadUInt32(); uint offset2 = br.ReadUInt32(); uint offset3 = br.ReadUInt32(); // Always 0x00 ? br.BaseStream.Position = offset1 + 0x1C; uint paletteOffset = br.ReadUInt32(); br.BaseStream.Position = 0x10; byte[] tiles = br.ReadBytes((int)(paletteOffset - 0x10)); br.BaseStream.Position = paletteOffset; Color[] colors = Actions.BGR555ToColor(br.ReadBytes(0x200)); RawPalette palette = new RawPalette(new Color[][] { colors }, false, ColorFormat.colors256, ""); pluginHost.Set_Palette(palette); br.Close(); Set_Tiles(tiles, 0x100, tiles.Length / 0x100, ColorFormat.colors256, TileForm.Lineal, false, 8); pluginHost.Set_Image(this); }