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 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 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 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); } }
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 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); }
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 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); }
private void btnExtract_Click(object sender, EventArgs e) { FolderBrowserDialog o = new FolderBrowserDialog(); o.Description = "Select the folder to save the sprites."; o.ShowNewFolderButton = true; if (o.ShowDialog() != DialogResult.OK) return; this.Cursor = Cursors.WaitCursor; string folderOut = o.SelectedPath + Path.DirectorySeparatorChar; for (int i = 0; i < imgs.Length; i++) { if (palettes[i] == null) palettes[i] = Save_File(palettes_[i]); BinaryReader br = new BinaryReader(File.OpenRead(palettes[i])); br.BaseStream.Position = 0x3340; Color[][] pal = new Color[1][] { Actions.BGR555ToColor(br.ReadBytes(0x40)) }; br.Close(); palette = new RawPalette(pal, false, ColorFormat.colors16); if (imgs[i] == null) imgs[i] = Save_File(imgs_[i]); uint max_imgs = (uint)(new FileInfo(imgs[i]).Length / 0x200); br = new BinaryReader(File.OpenRead(imgs[i])); for (int j = 0; j < max_imgs; j++) { br.BaseStream.Position = j * 0x200; byte[] tiles = br.ReadBytes(0x200); ImageBase image = new RawImage(tiles, TileForm.Lineal, ColorFormat.colors16, 0x20, 0x20, false); image.Get_Image(palette).Save(folderOut + "Sprite" + i.ToString() + '_' + j.ToString() + ".png"); } br.Close(); } this.Cursor = Cursors.Default; }
private void numSprite_ValueChanged(object sender, EventArgs e) { int i = (int)numFile.Value; int j = (int)numSprite.Value; BinaryReader br = new BinaryReader(File.OpenRead(imgs[i])); br.BaseStream.Position = j * 0x200; byte[] tiles = br.ReadBytes(0x200); br.Close(); ImageBase image = new RawImage(tiles, TileForm.Lineal, ColorFormat.colors16, 0x20, 0x20, false); this.Controls.Remove(imageControl1); imageControl1 = new ImageControl(pluginHost, image, palette); this.Controls.Add(imageControl1); }
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); }