public void Import(ReadAndWrite rw, Bitmap bm, int frame, int pal, bool clear, bool find) { int gfx_offset = npc.gfx_table + (frame << 3); int img_offset; try { img_offset = rw.ReadPointer(gfx_offset); if (clear) { rw.FillWith0xFF(img_offset, rw.Br.ReadInt16()); goto FIND; } if (clear || find) { goto FIND; } goto NOT_FIND; } catch (NullReferenceException) { } FIND: img_offset = rw.FindFreeOffset0xFF(PokeConfig.ini.start_offset, bm.Width * bm.Height / 2); NOT_FIND: byte[] img = ImgFunction.ConvertNormalImagToGBA(bm, new List <Color>(palletes[pal]), false); rw.WriteBytes(img_offset, 0, img); rw.Seek(gfx_offset); rw.Bw.Write(img_offset + ReadAndWrite.ROM); rw.Bw.Write(bm.Width * bm.Height >> 1); npc.width = (short)bm.Width; npc.height = (short)bm.Height; Save(rw); }
public void PreImport(Bitmap front, Bitmap shinyfront, Bitmap back, Bitmap shinyback) { this.front.Image = front; this.shinyfront.Image = shinyfront; this.back.Image = back; this.shinyback.Image = shinyback; List <Color> normal = new List <Color>(16); List <Color> shiny = new List <Color>(16); ImgFunction.GetImgColor(front, shinyfront, normal, shiny); frontdata = ImgFunction.ConvertNormalImagToGBA(front, normal); backdata = ImgFunction.ConvertNormalImagToGBA(back, normal); normalpallete = ImgFunction.LZCompress(ImgFunction.ConvertToGBAPal(normal)); shinypallete = ImgFunction.LZCompress(ImgFunction.ConvertToGBAPal(shiny)); preImport = true; }