public override void Write(string fileOut, ImageBase image, PaletteBase palette) { Update_Struct(); BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileOut)); // Common header bw.Write(nscr.header.id); bw.Write(nscr.header.endianess); bw.Write(nscr.header.constant); bw.Write(nscr.header.file_size); bw.Write(nscr.header.header_size); bw.Write(nscr.header.nSection); // SCRN section bw.Write(nscr.nrcs.id); bw.Write(nscr.nrcs.section_size); bw.Write(nscr.nrcs.width); bw.Write(nscr.nrcs.height); bw.Write(nscr.nrcs.padding); bw.Write(nscr.nrcs.data_size); for (int i = 0; i < nscr.nrcs.mapData.Length; i++) { int npalette = nscr.nrcs.mapData[i].nPalette << 12; int yFlip = nscr.nrcs.mapData[i].yFlip << 11; int xFlip = nscr.nrcs.mapData[i].xFlip << 10; int data = npalette + yFlip + xFlip + nscr.nrcs.mapData[i].nTile; bw.Write((ushort)data); } bw.Flush(); bw.Close(); }
public SpriteControl(IPluginHost pluginHost, SpriteBase sprite, ImageBase image, PaletteBase palette) { InitializeComponent(); this.sprite = sprite; this.image = image; this.palette = palette; this.pluginHost = pluginHost; Read_Language(); Update_Info(); }
public SpriteControl(IPluginHost pluginHost) { InitializeComponent(); this.pluginHost = pluginHost; this.sprite = pluginHost.Get_Sprite(); this.image = pluginHost.Get_Image(); this.palette = pluginHost.Get_Palette(); Read_Language(); Update_Info(); }
public override void Write(string fileout, ImageBase image, PaletteBase palette) { BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileout)); bw.Write((ushort)(Width / 0x08)); bw.Write((ushort)(Height / 0x08)); for (int i = 0; i < Map.Length; i++) bw.Write(Actions.MapInfo(Map[i])); bw.Flush(); bw.Close(); }
public ImageControl(IPluginHost pluginHost, ImageBase image, PaletteBase palette) { InitializeComponent(); isMap = false; this.image = image; this.palette = palette; this.pluginHost = pluginHost; Update_Info(); this.comboDepth.SelectedIndexChanged += new EventHandler(comboDepth_SelectedIndexChanged); this.numericWidth.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericHeight.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericStart.ValueChanged += new EventHandler(numericStart_ValueChanged); ReadLanguage(); Update_Image(); }
public ImageControl(IPluginHost pluginHost, bool isMap) { InitializeComponent(); this.pluginHost = pluginHost; this.isMap = isMap; this.palette = pluginHost.Get_Palette(); this.image = pluginHost.Get_Image(); if (isMap) this.map = pluginHost.Get_Map(); Update_Info(); this.comboDepth.SelectedIndexChanged += new EventHandler(comboDepth_SelectedIndexChanged); this.numericWidth.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericHeight.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericStart.ValueChanged += new EventHandler(numericStart_ValueChanged); ReadLanguage(); Update_Image(); }
public override void Write(string fileOut, ImageBase image, PaletteBase palette) { BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileOut)); bw.Write(scx.type); bw.Write(scx.unknown1); bw.Write(scx.unknown2); bw.Write(scx.unknown3); bw.Write(scx.unknown4); bw.Write((ushort)Width); bw.Write((ushort)Height); bw.Write(Map.Length * 2); bw.Write(Map.Length * 2); for (int i = 0; i < Map.Length; i++) bw.Write(Actions.MapInfo(Map[i])); bw.Flush(); bw.Close(); }
public ImageControl(XElement lang, ImageBase image, PaletteBase palette, MapBase map) { InitializeComponent(); this.isMap = true; this.palette = palette; this.image = image; this.map = map; Update_Info(); btnImport.Enabled = false; groupBox2.Enabled = false; this.comboDepth.SelectedIndexChanged += new EventHandler(comboDepth_SelectedIndexChanged); this.numericWidth.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericHeight.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericStart.ValueChanged += new EventHandler(numericStart_ValueChanged); ReadLanguage(lang); Update_Image(); }
public ImageControl(IPluginHost pluginHost, bool isMap) { InitializeComponent(); this.pluginHost = pluginHost; this.isMap = isMap; this.palette = pluginHost.Get_Palette(); this.image = pluginHost.Get_Image(); if (isMap) { this.map = pluginHost.Get_Map(); } Update_Info(); this.comboDepth.SelectedIndexChanged += new EventHandler(comboDepth_SelectedIndexChanged); this.numericWidth.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericHeight.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericStart.ValueChanged += new EventHandler(numericStart_ValueChanged); ReadLanguage(); Update_Image(); }
public override void Write(string fileOut, ImageBase image, PaletteBase palette) { throw new NotImplementedException(); }
public void Read12(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Read header ushort bpp = br.ReadUInt16(); int width = br.ReadByte() * 8; int height = br.ReadByte() * 8; ushort map_offset = br.ReadUInt16(); ushort map_size = br.ReadUInt16(); ushort data_offset = br.ReadUInt16(); ushort data_size = br.ReadUInt16(); ushort pal_offset = br.ReadUInt16(); ushort pal_size = br.ReadUInt16(); // Read map br.BaseStream.Position = map_offset; NTFS[] map = new NTFS[map_size / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); Set_Map(map, false, width, height); // Read image data ColorFormat format = ColorFormat.colors256; if (bpp == 0x12 || bpp == 0x1A) format = ColorFormat.colors16; else if (bpp == 0x10 || bpp == 0x18) format = ColorFormat.colors256; br.BaseStream.Position = data_offset; byte[] data = br.ReadBytes(data_size); Encryption enc = new Encryption(data); data = enc.Decrypt(); img = new RawImage(data, TileForm.Horizontal, format, width, height, false); // Read palette if ((bpp == 0x18 || bpp == 0x1A) && pluginHost.Get_Palette().Loaded) pal = pluginHost.Get_Palette(); else { br.BaseStream.Position = pal_offset; Color[] colors = Actions.BGR555ToColor(br.ReadBytes(pal_size)); pal = new RawPalette(new Color[][] { colors }, false, ColorFormat.colors16); } br.Close(); ismap = true; Console.WriteLine("Image with bpp: {0}", bpp.ToString("x")); }
public Image Get_Image(ImageBase image, PaletteBase pal, int index, int width, int height, bool grid, bool cell, bool number, bool trans, bool img, int currOAM, int[] draw_index) { return(Actions.Get_Image(banks[index], block_size, image, pal, width, height, grid, cell, number, trans, img, currOAM, 1, draw_index)); }
public Image Get_Image(ImageBase image, PaletteBase pal, Bank bank, int width, int height, bool grid, bool cell, bool number, bool trans, bool img, int currOAM) { return(Actions.Get_Image(bank, block_size, image, pal, width, height, grid, cell, number, trans, img, currOAM)); }
public void Set_Image(ImageBase image) { this.image = image; }
public static Bitmap Get_Image(Bank bank, uint blockSize, ImageBase img, PaletteBase pal, int max_width, int max_height, bool draw_grid, bool draw_cells, bool draw_numbers, bool trans, bool image, int currOAM = -1, int zoom = 1, int[] index = null) { Size size = new Size(max_width * zoom, max_height * zoom); Bitmap bank_img = new Bitmap(size.Width, size.Height); Graphics graphic = Graphics.FromImage(bank_img); if (bank.oams.Length == 0) { graphic.DrawString("No OAM", SystemFonts.CaptionFont, Brushes.Black, new PointF(max_width / 2, max_height / 2)); return bank_img; } if (draw_grid) { for (int i = (0 - size.Width); i < size.Width; i += 8) { graphic.DrawLine(Pens.LightBlue, (i + size.Width / 2) * zoom, 0, (i + size.Width / 2) * zoom, size.Height * zoom); graphic.DrawLine(Pens.LightBlue, 0, (i + size.Height / 2) * zoom, size.Width * zoom, (i + size.Height / 2) * zoom); } graphic.DrawLine(Pens.Blue, (max_width / 2) * zoom, 0, (max_width / 2) * zoom, max_height * zoom); graphic.DrawLine(Pens.Blue, 0, (max_height / 2) * zoom, max_width * zoom, (max_height / 2) * zoom); } Image cell; for (int i = 0; i < bank.oams.Length; i++) { bool draw = false; if (index == null) draw = true; else for (int k = 0; k < index.Length; k++) if (index[k] == i) draw = true; if (!draw) continue; if (bank.oams[i].width == 0x00 || bank.oams[i].height == 0x00) continue; uint tileOffset = bank.oams[i].obj2.tileOffset; tileOffset = (uint)(tileOffset << (byte)blockSize); if (image) { ImageBase cell_img = new TestImage(); cell_img.Set_Tiles((byte[])img.Tiles.Clone(), bank.oams[i].width, bank.oams[i].height, img.FormatColor, img.FormTile, false); cell_img.StartByte = (int)(tileOffset * 0x20 + bank.data_offset); byte num_pal = bank.oams[i].obj2.index_palette; if (num_pal >= pal.NumberOfPalettes) num_pal = 0; for (int j = 0; j < cell_img.TilesPalette.Length; j++) cell_img.TilesPalette[j] = num_pal; cell = cell_img.Get_Image(pal); //else //{ // tileOffset /= (blockSize / 2); // int imageWidth = img.Width; // int imageHeight = img.Height; // int posX = (int)(tileOffset % imageWidth); // int posY = (int)(tileOffset / imageWidth); // if (img.ColorFormat == ColorFormat.colors16) // posY *= (int)blockSize * 2; // else // posY *= (int)blockSize; // if (posY >= imageHeight) // posY = posY % imageHeight; // cells[i] = ((Bitmap)img.Get_Image(pal)).Clone(new Rectangle(posX * zoom, posY * zoom, bank.oams[i].width * zoom, bank.oams[i].height * zoom), // System.Drawing.Imaging.PixelFormat.DontCare); //} #region Flip if (bank.oams[i].obj1.flipX == 1 && bank.oams[i].obj1.flipY == 1) cell.RotateFlip(RotateFlipType.RotateNoneFlipXY); else if (bank.oams[i].obj1.flipX == 1) cell.RotateFlip(RotateFlipType.RotateNoneFlipX); else if (bank.oams[i].obj1.flipY == 1) cell.RotateFlip(RotateFlipType.RotateNoneFlipY); #endregion if (trans) ((Bitmap)cell).MakeTransparent(pal.Palette[num_pal][0]); graphic.DrawImageUnscaled(cell, size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom); } if (draw_cells) graphic.DrawRectangle(Pens.Black, size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom, bank.oams[i].width * zoom, bank.oams[i].height * zoom); if (i == currOAM) graphic.DrawRectangle(new Pen(Color.Red, 3), size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom, bank.oams[i].width * zoom, bank.oams[i].height * zoom); if (draw_numbers) graphic.DrawString(bank.oams[i].num_cell.ToString(), SystemFonts.CaptionFont, Brushes.Black, size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom); } return bank_img; }
public ImageControl(XElement lang, ImageBase image, PaletteBase palette) { InitializeComponent(); isMap = false; this.image = image; this.palette = palette; Update_Info(); btnImport.Enabled = false; groupBox2.Enabled = false; this.comboDepth.SelectedIndexChanged += new EventHandler(comboDepth_SelectedIndexChanged); this.numericWidth.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericHeight.ValueChanged += new EventHandler(numericSize_ValueChanged); this.numericStart.ValueChanged += new EventHandler(numericStart_ValueChanged); ReadLanguage(lang); Update_Image(); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); uint header = br.ReadUInt32(); uint pal_length = br.ReadUInt32(); uint tile_length = br.ReadUInt32(); uint map_length = br.ReadUInt32(); ColorFormat depth = (pal_length < 0x200 ? ColorFormat.colors16 : ColorFormat.colors256); isMap = true; int width, height; if (header == 0x18) { width = (ushort)br.ReadUInt32(); height = (ushort)br.ReadUInt32(); } else { width = 0x200; height = 0xc0; isMap = false; } // Palette int num_colors = (depth == ColorFormat.colors16 ? 0x10 : 0x100); Color[][] colors = new Color[pal_length / (num_colors * 2)][]; for (int i = 0; i < colors.Length; i++) colors[i] = Actions.BGR555ToColor(br.ReadBytes((int)(num_colors * 2))); palette = new RawPalette(colors, false, depth, fileName); // Tile data Byte[] tiles = br.ReadBytes((int)tile_length); image = new RawImage(tiles, TileForm.Horizontal, depth, width, height, false, fileName); // Map if (isMap) { NTFS[] maps = new NTFS[map_length / 2]; for (int i = 0; i < maps.Length; i++) maps[i] = Actions.MapInfo(br.ReadUInt16()); Set_Map(maps, false); } br.Close(); }
public Image Get_Image(ImageBase image, PaletteBase pal, int index, int width, int height, bool grid, bool cell, bool number, bool trans, bool img, int currOAM, int[] draw_index) { return Actions.Get_Image(banks[index], block_size, image, pal, width, height, grid, cell, number, trans, img, currOAM, 1, draw_index); }
public Image Get_Image(ImageBase image, PaletteBase pal, Bank bank, int width, int height, bool grid, bool cell, bool number, bool trans, bool img, int currOAM) { return Actions.Get_Image(bank, block_size, image, pal, width, height, grid, cell, number, trans, img, currOAM); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Header uint paletaOffset = br.ReadUInt32() * 4; uint tileOffset = br.ReadUInt32() * 4; uint mapOffset = br.ReadUInt32() * 4; // Paleta br.BaseStream.Position = paletaOffset; uint pCabeceraSize = br.ReadUInt32() * 4; uint pSize = br.ReadUInt32() * 4; Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)(pSize - 0x08))); palette = new RawPalette(colors, false, ColorFormat.colors256); // Image data br.BaseStream.Position = tileOffset; uint tCabeceraSize = br.ReadUInt32() * 4; uint tSize = br.ReadUInt32() * 4; byte[] tiles = br.ReadBytes((int)(tSize - 0x08)); image = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, 256, 192, false); // Map br.BaseStream.Position = mapOffset; uint mCabeceraSize = br.ReadUInt32() * 4; uint mSize = br.ReadUInt32() * 4; ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); NTFS[] map = new NTFS[(mSize - 0x08) / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); Set_Map(map, false, width * 8, height * 8); }
public override void Write(string fileOut, ImageBase image, PaletteBase palette) { }
public override void Read(string fileIn) { ncob = new sNCOB(); BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Read the header ncob.generic.id = br.ReadChars(4); ncob.generic.endianess = br.ReadUInt16(); ncob.generic.constant = br.ReadUInt16(); ncob.generic.file_size = br.ReadUInt32(); ncob.generic.header_size = br.ReadUInt16(); ncob.generic.nSection = br.ReadUInt16(); for (int i = 0; i < ncob.generic.nSection; i++) { string type = new String(br.ReadChars(4)); switch (type) { case "CELL": ncob.cell.type = "CELL".ToCharArray(); ncob.cell.size = br.ReadUInt32(); ncob.cell.num_banks = br.ReadUInt32(); ncob.cell.banks = new Ekona.Images.Bank[ncob.cell.num_banks]; for (int b = 0; b < ncob.cell.num_banks; b++) { ncob.cell.banks[b] = new Ekona.Images.Bank(); ncob.cell.banks[b].oams = new OAM[br.ReadUInt32()]; for (int o = 0; o < ncob.cell.banks[b].oams.Length; o++) { OAM oam = new OAM(); oam.obj1.xOffset = br.ReadInt16(); oam.obj0.yOffset = br.ReadInt16(); ushort unk1 = br.ReadUInt16(); if (unk1 != 0) System.Windows.Forms.MessageBox.Show("Unk1 different to 0"); oam.obj1.flipX = br.ReadByte(); oam.obj1.flipY = br.ReadByte(); uint unk2 = br.ReadUInt32(); if (unk2 != 0) System.Windows.Forms.MessageBox.Show("Unk2 different to 0"); oam.obj0.shape = br.ReadByte(); oam.obj1.size = br.ReadByte(); oam.obj2.priority = br.ReadByte(); oam.obj2.index_palette = br.ReadByte(); oam.obj2.tileOffset = br.ReadUInt32(); oam.width = (ushort)Actions.Get_OAMSize(oam.obj0.shape, oam.obj1.size).Width; oam.height = (ushort)Actions.Get_OAMSize(oam.obj0.shape, oam.obj1.size).Height; oam.num_cell = (ushort)o; ncob.cell.banks[b].oams[o] = oam; } } break; case "CHAR": ncob.chars.type = "CHAR".ToCharArray(); ncob.chars.size = br.ReadUInt32(); ncob.chars.unknown = br.ReadUInt32(); ncob.chars.data_size = br.ReadUInt32(); ncob.chars.data = br.ReadBytes((int)ncob.chars.data_size); break; default: uint size = br.ReadUInt32(); br.BaseStream.Position += size - 8; break; } } br.Close(); img = new RawImage(ncob.chars.data, TileForm.Horizontal, ColorFormat.colors16, 0x20, ncob.chars.data.Length / 0x20, false); Set_Banks(ncob.cell.banks, 0, false); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); ushort h = br.ReadUInt16(); if (h == 0x10 || h == 0x12 || h == 0x18 || h == 0x1A) { br.Close(); Read12(fileIn); return; } br.BaseStream.Position = 0; uint info_offset = br.ReadUInt32(); uint data_size = br.ReadUInt32(); byte[] data; if ((data_size >> 31) == 1) { // Data encoded data_size = data_size & 0xFFFFFF; data = br.ReadBytes((int)data_size); Encryption enc = new Encryption(data); data = enc.Decrypt(); } else data = br.ReadBytes((int)data_size); br.BaseStream.Position = info_offset + 4; uint pal_offset = br.ReadUInt32(); uint unk_offset = br.ReadUInt32(); // Get palette br.BaseStream.Position = pal_offset + 4; Color[] colors = Actions.BGR555ToColor(br.ReadBytes(0x200)); pal = new RawPalette(new Color[][] { colors }, false, ColorFormat.colors256); // Unknown (probably like a map) br.BaseStream.Position = unk_offset; int width = br.ReadByte() * 8; int height = br.ReadByte() * 8; img = new RawImage(data, TileForm.Horizontal, ColorFormat.colors256, width, height, false); ismap = false; br.Close(); }
public void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); // Header uint paletaOffset = br.ReadUInt32() * 4; uint tileOffset = br.ReadUInt32() * 4; uint mapOffset = br.ReadUInt32() * 4; ColorFormat depth; br.BaseStream.Position = mapOffset; if (br.ReadUInt32() == 0x01) depth = ColorFormat.colors256; else depth = ColorFormat.colors16; // Palette Color[][] colors; if (paletaOffset == 0x00) // No palette { depth = ColorFormat.colors16; colors = new Color[defaultPaletteData.Length / 0x20][]; for (int i = 0; i < colors.Length; i++) { Byte[] data = new Byte[0x20]; Array.Copy(defaultPaletteData, i * 0x20, data, 0, 0x20); colors[i] = Actions.BGR555ToColor(data); } goto Tile; } br.BaseStream.Position = paletaOffset; uint pCabeceraSize = br.ReadUInt32() * 4; uint pSize = br.ReadUInt32() * 4; if (pSize - 0x08 == 0x0200) depth = ColorFormat.colors256; else if (pSize - 0x08 == 0x20) depth = ColorFormat.colors16; colors = new Color[depth == ColorFormat.colors16 ? (pSize - 0x08) / 0x20 : 1][]; uint pal_length = (depth == ColorFormat.colors16) ? 0x20 : pSize - 0x08; for (int i = 0; i < colors.Length; i++) colors[i] = Actions.BGR555ToColor(br.ReadBytes((int)pal_length)); // Tile data Tile: br.BaseStream.Position = tileOffset; uint tCabeceraSize = br.ReadUInt32() * 4; uint tSize = br.ReadUInt32() * 4; byte[] tiles = br.ReadBytes((int)(tSize - 0x08)); image = new RawImage(tiles, TileForm.Horizontal, depth, 0x40, tiles.Length / 0x40, false, fileName); // Map if (mapOffset == 0x00) { hasMap = false; goto End; } hasMap = true; br.BaseStream.Position = mapOffset; uint mCabeceraSize = br.ReadUInt32() * 4; uint[] mSize = new uint[(int)mCabeceraSize / 4]; for (int i = 0; i < mSize.Length; i++) mSize[i] = (br.ReadUInt32() * 4) - mCabeceraSize - 4; maps = new MapBase[mSize.Length]; for (int i = 0; i < maps.Length; i++) { ushort width = (ushort)(br.ReadUInt16() * 8); ushort height = (ushort)(br.ReadUInt16() * 8); NTFS[] map; if (i != 0) map = new NTFS[((mSize[i] - mSize[i - 1]) - 4) / 2]; else map = new NTFS[(mSize[i] - 4) / 2]; for (int j = 0; j < map.Length; j++) map[j] = Actions.MapInfo(br.ReadUInt16()); maps[i] = new RawMap(map, width, height, false, fileName); } End: br.Close(); palette = new RawPalette(colors, false, depth, fileName); }
public override void Write(string fileOut, ImageBase image, PaletteBase palette) { BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileOut)); bw.Write(prev_data); for (int i = 0; i < Map.Length; i++) bw.Write(Actions.MapInfo(Map[i])); bw.Write(next_data); bw.Flush(); bw.Close(); }
public override void Write(string fileOut, ImageBase image, PaletteBase palette) { Update_Struct(); BinaryWriter bw = new BinaryWriter(File.OpenWrite(fileOut)); // Generic header bw.Write(ncer.header.id); bw.Write(ncer.header.endianess); bw.Write(ncer.header.constant); bw.Write(ncer.header.file_size); bw.Write(ncer.header.header_size); bw.Write(ncer.header.nSection); // CEBK section (CEll BanK) bw.Write(ncer.cebk.id); bw.Write(ncer.cebk.section_size); bw.Write(ncer.cebk.nBanks); bw.Write(ncer.cebk.tBank); bw.Write(ncer.cebk.bank_data_offset); bw.Write(ncer.cebk.block_size); bw.Write(ncer.cebk.partition_data_offset); bw.Write(ncer.cebk.unused); // Banks for (int i = 0; i < ncer.cebk.banks.Length; i++) { bw.Write(ncer.cebk.banks[i].nCells); bw.Write(ncer.cebk.banks[i].readOnlyCellInfo); bw.Write(ncer.cebk.banks[i].cell_offset); if (ncer.cebk.tBank == 1) { bw.Write(ncer.cebk.banks[i].xMax); bw.Write(ncer.cebk.banks[i].yMax); bw.Write(ncer.cebk.banks[i].xMin); bw.Write(ncer.cebk.banks[i].yMin); } } // OAMs for (int i = 0; i < ncer.cebk.banks.Length; i++) { for (int j = 0; j < ncer.cebk.banks[i].nCells; j++) { OAM oam = ncer.cebk.banks[i].oams[j]; ushort[] obj = Actions.OAMInfo(oam); bw.Write(BitConverter.GetBytes(obj[0])); bw.Write(BitConverter.GetBytes(obj[1])); bw.Write(BitConverter.GetBytes(obj[2])); } } while (bw.BaseStream.Position % 4 != 0) bw.Write((byte)0x00); // Partition data if (ncer.cebk.partition_data_offset != 0) { bw.Write(ncer.cebk.max_partition_size); bw.Write(ncer.cebk.first_partition_data_offset); for (int i = 0; i < ncer.cebk.banks.Length; i++) { bw.Write(ncer.cebk.banks[i].partition_offset); bw.Write(ncer.cebk.banks[i].partition_size); } } // LBAL section if (new string(ncer.labl.id) == "LBAL" || new string(ncer.labl.id) == "LABL") { bw.Write(ncer.labl.id); bw.Write(ncer.labl.section_size); for (int i = 0; i < ncer.labl.offset.Length; i++) bw.Write(ncer.labl.offset[i]); for (int i = 0; i < ncer.labl.offset.Length; i++) bw.Write((ncer.labl.names[i] + '\0').ToCharArray()); } // UEXT section if (new string(ncer.uext.id) == "UEXT" || new string(ncer.uext.id) == "TXEU") { bw.Write(ncer.uext.id); bw.Write(ncer.uext.section_size); bw.Write(ncer.uext.unknown); } bw.Flush(); bw.Close(); }
public SpriteControl(XElement lang, SpriteBase sprite, ImageBase image, PaletteBase palette) { InitializeComponent(); this.sprite = sprite; this.image = image; this.palette = palette; this.lang = lang; Read_Language(lang); Update_Info(); }
public Image Get_Image(ImageBase image, PaletteBase palette) { if (image.FormTile == TileForm.Lineal) image.FormTile = TileForm.Horizontal; Byte[] tiles, tile_pal; NTFS[] currMap = (NTFS[])map.Clone(); tiles = Actions.Apply_Map(currMap, image.Tiles, out tile_pal, image.BPP, image.TileSize); ImageBase newImage = new TestImage(); newImage.Set_Tiles(tiles, image.Width, image.Height, image.FormatColor, image.FormTile, image.CanEdit, image.TileSize); newImage.TilesPalette = tile_pal; newImage.Zoom = image.Zoom; if (height != 0) newImage.Height = height; if (width != 0) newImage.Width = width; return newImage.Get_Image(palette); }
public abstract void Write(string fileOut, ImageBase image, PaletteBase palette);
public void Set_Tiles(ImageBase new_img) { this.tiles = new_img.Tiles; this.format = new_img.FormatColor; this.tileForm = new_img.FormTile; this.tile_size = new_img.tile_size; Width = new_img.Width; Height = new_img.Height; zoom = 1; startByte = 0; loaded = true; bpp = 8; if (format == Images.ColorFormat.colors16) bpp = 4; else if (format == Images.ColorFormat.colors2) bpp = 1; else if (format == Images.ColorFormat.colors4) bpp = 2; else if (format == Images.ColorFormat.direct) bpp = 16; else if (format == Images.ColorFormat.BGRA32 || format == Images.ColorFormat.ABGR32) bpp = 32; tilePal = new byte[tiles.Length * (tile_size / bpp)]; // Get the original data for changes in startByte original = (byte[])tiles.Clone(); }
public AnimationControl(IPluginHost pluginHost, NANR ani) { InitializeComponent(); Read_Language(); this.pluginHost = pluginHost; this.palette = pluginHost.Get_Palette(); this.image = pluginHost.Get_Image(); this.sprite = pluginHost.Get_Sprite(); this.ani = ani; isAni = true; if (ani.Struct.abnk.nBanks == 0) { MessageBox.Show("No animations."); isAni = false; tempo.Enabled = false; comboAni.Enabled = false; btnNext.Enabled = false; btnPlay.Enabled = false; btnPrevious.Enabled = false; btnSave.Enabled = false; btnStop.Enabled = false; txtTime.Enabled = false; checkCeldas.Enabled = false; checkEntorno.Enabled = false; checkImage.Enabled = false; checkNumeros.Enabled = false; checkTransparencia.Enabled = false; } for (int i = 0; i < ani.Names.Length; i++) comboAni.Items.Add(ani.Names[i]); if (isAni) comboAni.SelectedIndex = 0; ShowInfo(); Get_Ani(); tempo.Stop(); tempo.Interval = Convert.ToInt32(txtTime.Text); if (isAni) aniBox.Image = bitAni[0]; }
public void Get_Image(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Palette uint num_colors = br.ReadUInt32(); Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)num_colors * 2)); // Image data uint num_tiles = (ushort)br.ReadUInt32(); byte[] tiles = br.ReadBytes((int)num_tiles * 0x40); // Map Info ushort width = (ushort)(br.ReadUInt16() * 8); ushort height = (ushort)(br.ReadUInt16() * 8); NTFS[] map = new NTFS[width * height / 0x40]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); palette = new RawPalette(colors, false, ColorFormat.colors256); image = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, width, height, false); Set_Map(map, false, width, height); }