예제 #1
0
 public void drawSprite()
 {
     if (bmp == null)
     {
         return;
     }
     try
     {
         label4.Text = String.Format("sprite {0:d} of {1:d}", curspr, spr.header.n_sprites);
         byte[]   data = spr.frame(curspr);
         BPalette pal  = getSelectedPalette(comboBox1);
         for (int i = 0; i < spr.header.height; i++)
         {
             for (int j = 0; j < spr.header.width; j++)
             {
                 int   idx = i * spr.header.width + j;
                 Color cl;
                 if (idx < data.Length)
                 {
                     cl = pal.getPal()[data[idx]];
                 }
                 else
                 {
                     cl = Color.Red;
                 }
                 bmp.SetPixel(j, i, cl);
             }
         }
     }
     catch (Exception ex)
     {
         MainForm.clearResource(ex);
     }
     pictureBox1.Refresh();
 }
예제 #2
0
 protected BPalette getSelectedPalette(ComboBox box)
 {
     if (box.SelectedIndex < 0)
     {
         return(BPalette.GrayScalePalette());
     }
     else
     {
         return(Config.get().findPalette(box.Text));
     }
 }