Ejemplo n.º 1
0
        private void exportBmpMenuItem_Click(object sender, EventArgs e)
        {
            Sprite currentSprite    = allSpritesEditor1.CurrentSprite;
            int    paletteIndex     = allSpritesEditor1.PaletteIndex;
            bool   importExport8Bpp = allSpritesEditor1.ImportExport8Bpp;

            saveFileDialog.Filter          = importExport8Bpp ? "8bpp paletted bitmap (*.BMP)|*.bmp" : "4bpp paletted bitmap (*.BMP)|*.bmp";
            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.CreatePrompt    = false;
            saveFileDialog.FileName        = string.Empty;

            if (currentSprite != null && saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                AbstractSprite sprite = currentSprite.GetAbstractSpriteFromIso(currentStream, true);
                Bitmap         bitmap = importExport8Bpp ? sprite.ToBitmap() : sprite.To4bppBitmapUncached(paletteIndex);
                bitmap.Save(saveFileDialog.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
            }
        }
Ejemplo n.º 2
0
        private AllSpritesDoWorkResult DumpAllSprites(Stream iso, string path, bool importExport8bpp, int paletteIndex, Action <int> progressReporter)
        {
            bool progress        = progressReporter != null;
            int  total           = 0;
            int  complete        = 0;
            int  imagesProcessed = 0;

            /*
             * if (progress)
             *  sprites.ForEach(i => total += 1);
             */

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            Dictionary <string, Sprite> fileMap = new Dictionary <string, Sprite>();

            foreach (Sprite sprite in sprites)
            {
                string name = sprite.GetSaveFileName();
                if (!fileMap.ContainsKey(name))
                {
                    fileMap.Add(name, sprite);
                    total = total + 1;
                }
            }

            //foreach (Sprite sprite in sprites)
            foreach (KeyValuePair <string, Sprite> singleFileMap in fileMap)
            {
                //string name = string.Empty;
                //name = sprite.GetSaveFileName();
                string name = singleFileMap.Key;

                if (!string.IsNullOrEmpty(name))
                {
                    //Bitmap bmp = img.GetImageFromIso( iso );
                    //bmp.Save( Path.Combine( path, name ), System.Drawing.Imaging.ImageFormat.Bmp );
                    string                fullPath       = Path.Combine(path, name);
                    Sprite                sprite         = singleFileMap.Value;
                    AbstractSprite        abstractSprite = sprite.GetAbstractSpriteFromIso(iso, true);
                    System.Drawing.Bitmap bitmap         = importExport8bpp ? abstractSprite.ToBitmap() : abstractSprite.To4bppBitmapUncached(paletteIndex);
                    bitmap.Save(fullPath, System.Drawing.Imaging.ImageFormat.Bmp);

                    imagesProcessed++;
                }

                if (progress)
                {
                    progressReporter((100 * (complete++)) / total);
                }
            }

            return(new AllSpritesDoWorkResult(AllSpritesDoWorkResult.Result.Success, imagesProcessed));
        }