예제 #1
0
 private void ExportILBMMenu_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter = "Deluxe Paint Brush|*.bbm";
     if (panel.SelectedIndices.Count > 1)
     {
         saveFileDialog1.FileName = "ignored";
     }
     else
     {
         saveFileDialog1.FileName = ImageFilename(panel.SelectedIndices[0]);//listView1.Items[listView1.SelectedIndices[0]].Text;
     }
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if (panel.SelectedIndices.Count > 1)
         {
             string directory = Path.GetDirectoryName(saveFileDialog1.FileName);
             foreach (int index in panel.SelectedIndices)
             {
                 PIGImage     image   = datafile.Bitmaps[index];
                 string       newpath = directory + Path.DirectorySeparatorChar + ImageFilename(index) + ".bbm";
                 BinaryWriter bw      = new BinaryWriter(File.Open(newpath, FileMode.Create));
                 lbmDecoder.WriteBBM(image, palette, bw);
                 bw.Flush();
                 bw.Close();
                 bw.Dispose();
             }
         }
         else
         {
             if (saveFileDialog1.FileName != "")
             {
                 PIGImage     image = datafile.Bitmaps[panel.SelectedIndices[0]];
                 BinaryWriter bw    = new BinaryWriter(File.Open(saveFileDialog1.FileName, FileMode.Create));
                 lbmDecoder.WriteBBM(image, palette, bw);
                 bw.Flush();
                 bw.Close();
                 bw.Dispose();
             }
         }
     }
 }
예제 #2
0
        public static void DumpPIGToBBM(PIGFile pigFile, Palette palette, string outputFilename)
        {
            LBMDecoder encoder   = new LBMDecoder();
            string     directory = Path.GetDirectoryName(outputFilename);

            int numFrames = 0;

            PIGImage[] frames = new PIGImage[50];
            PIGImage   image;

            for (int i = 0; i < pigFile.Bitmaps.Count; i++)
            {
                if (pigFile.Bitmaps[i].IsAnimated) //Special animation hacks
                {
                    image = pigFile.Bitmaps[i];
                    if (image.Frame == 0) //Start at the first frame
                    {
                        numFrames           = 0;
                        frames[numFrames++] = image;
                        if ((i + 1) >= pigFile.Bitmaps.Count)
                        {
                            return;                                   //out of images
                        }
                        while (image.Name == pigFile.Bitmaps[i + 1].Name)
                        {
                            frames[numFrames] = pigFile.Bitmaps[i + 1];
                            i++;
                            numFrames++;
                            if ((i + 1) >= pigFile.Bitmaps.Count)
                            {
                                break;                                   //out of images
                            }
                        }
                        BinaryWriter bw = new BinaryWriter(File.OpenWrite(string.Format("{0}{1}{2}.abm", directory, Path.DirectorySeparatorChar, image.Name)));
                        encoder.WriteABM(frames, numFrames, palette, bw);
                        bw.Close();
                        bw.Dispose();
                    }
                }
                else
                {
                    image = pigFile.Bitmaps[i];
                    BinaryWriter bw = new BinaryWriter(File.OpenWrite(string.Format("{0}{1}{2}.bbm", directory, Path.DirectorySeparatorChar, image.Name)));
                    encoder.WriteBBM(image, palette, bw);
                    bw.Close();
                    bw.Dispose();
                }
            }
        }