Пример #1
0
        public Bitmap getImg(int index)
        {
            int ofs = 0;

            for (int i = 0; i < index; i++)
            {
                ofs += sizes[i * 2] * sizes[i * 2 + 1];
            }
            int    w   = sizes[index * 2];
            int    h   = sizes[index * 2 + 1];
            Bitmap bmp = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);

            System.Drawing.Imaging.ColorPalette pal = bmp.Palette;
            Palette pl = Palettes.get().getPalette(comboBox2.Text);

            for (int i = 0; i < 256; i++)
            {
                pal.Entries[i] = pl.cls[i];
            }
            bmp.Palette = pal;
            byte[] data = new byte[w * h];
            Array.Copy(vga, ofs, data, 0, w * h);
            BitmapData bd = bmp.LockBits(new Rectangle(0, 0, w, h),
                                         ImageLockMode.WriteOnly, bmp.PixelFormat);

            for (int i = 0; i < bd.Height; i++)
            {
                System.Runtime.InteropServices.Marshal.Copy(data, (i * bd.Width), new IntPtr(bd.Scan0.ToInt64() + i * bd.Stride), bd.Width);
            }
            bmp.UnlockBits(bd);
            return(bmp);
        }
Пример #2
0
 public BmpView()
 {
     InitializeComponent();
     for (int i = 0; i < Palettes.get().pls.Count; i++)
     {
         comboBox2.Items.Add(Palettes.get().pls[i].name);
     }
 }
Пример #3
0
 public static Palettes get()
 {
     if (obj == null)
     {
         obj = new Palettes();
         obj.addPalette(new Palette(null,"",false));
     }
     return obj;
 }
Пример #4
0
 public static Palettes get()
 {
     if (obj == null)
     {
         obj = new Palettes();
         obj.addPalette(new Palette(null, "", false));
     }
     return(obj);
 }
Пример #5
0
        public BmpView(byte[] data, string name, bool scr) : this()
        {
            this.scr = scr;
            Text     = (scr?"SCR ":"BMP ") + name;
            byte[] vdt;
            if (scr)
            {
                cnt   = 1;
                sizes = new int[2] {
                    320, 200
                };
                comboBox1.Items.Add(0);
                try
                {
                    vdt = Common.getSection(data, "SCR:VGA:");
                }
                catch (PartNotFoundException)
                {
                    amg = true;
                    vdt = Common.getSection(data, "SCR:AMG:");
                }
                vga = Common.mixData(RBCompress.Decompressor.decompress(Common.getSection(data, "SCR:BIN:")),
                                     RBCompress.Decompressor.decompress(vdt), amg);
            }
            else
            {
                byte[] inf = Common.getSection(data, "BMP:INF:");
                cnt   = Common.readInt16(inf, 0);
                sizes = new int[cnt * 2];
                for (int i = 0; i < cnt; i++)
                {
                    sizes[i * 2]     = Common.readInt16(inf, i * 2 + 2);
                    sizes[i * 2 + 1] = Common.readInt16(inf, cnt * 2 + 2 + i * 2);
                    comboBox1.Items.Add(i);
                }
                try
                {
                    vdt = Common.getSection(data, "BMP:VGA:");
                }
                catch (PartNotFoundException)
                {
                    amg = true;
                    vdt = Common.getSection(data, "BMP:AMG:");
                }
                vga = Common.mixData(RBCompress.Decompressor.decompress(Common.getSection(data, "BMP:BIN:")),
                                     RBCompress.Decompressor.decompress(vdt), amg);
            }
            Palette pl = Palettes.get().getPalette(name);

            comboBox2.SelectedItem  = pl.name;
            comboBox1.SelectedIndex = 0;
            if (scr)
            {
                comboBox1.Enabled = false;
            }
        }
Пример #6
0
 private void tracePalettes()
 {
     foreach (ListViewItem li in listView1.Items)
     {
         string[] fname = li.SubItems[4].Text.Split('.');
         if (fname.Length > 1 && fname[1].ToLower() == "pal")
         {
             Palettes.get().AddPalette(getFile(li), fname[0], true);
         }
     }
 }
Пример #7
0
 public PalView(byte[] data, string name) : this()
 {
     Text     = "Palette " + name;
     this.pal = Palettes.get().getPalette(name);
     pictureBox1.Update();
 }