Example #1
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));
        }
Example #2
0
        /// <summary>
        /// Gets this frame from the specified sprite.
        /// </summary>
        public Bitmap GetFrame( AbstractSprite source )
        {
            Bitmap result = new Bitmap( 210, 160, System.Drawing.Imaging.PixelFormat.Format8bppIndexed );

            Bitmap sourceBmp = source.ToBitmap();
            result.Palette = sourceBmp.Palette;

            foreach ( Tile t in tiles )
            {
                sourceBmp.CopyRectangleToPoint( t.Rectangle, result, t.Location, source.Palettes[0], t.Reverse );
            }

            return result;
        }
Example #3
0
        /// <summary>
        /// Gets this frame from the specified sprite.
        /// </summary>
        public Bitmap GetFrame(AbstractSprite source)
        {
            Bitmap result = new Bitmap(210, 160, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);

            Bitmap sourceBmp = source.ToBitmap();

            result.Palette = sourceBmp.Palette;

            foreach (Tile t in tiles)
            {
                sourceBmp.CopyRectangleToPoint(t.Rectangle, result, t.Location, source.Palettes[0], t.Reverse);
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Gets this frame from the specified sprite.
        /// </summary>
        public Bitmap GetFrame(AbstractSprite source, int paletteIndex = 0)
        {
            Bitmap result = new Bitmap(defaultFrameSize.Width, defaultFrameSize.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);

            Bitmap sourceBmp = source.ToBitmap(paletteIndex, true);

            //sourceBmp = sourceBmp.RotateImg(90, Color.Transparent);
            result.Palette = sourceBmp.Palette;
            float rotation = 0;

            foreach (Tile t in tiles)
            {
                rotation = t.Rotation;
                sourceBmp.CopyRectangleToPoint(t.Rectangle, result, t.Location, source.Palettes[0], t.ReverseX, t.ReverseY);
            }

            return(result);
        }
Example #5
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);
            }
        }
Example #6
0
        /// <summary>
        /// Gets this frame from the specified sprite.
        /// </summary>
        public Bitmap GetFrame( AbstractSprite source )
        {
            Bitmap result = new Bitmap( defaultFrameSize.Width, defaultFrameSize.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed );

            Bitmap sourceBmp = source.ToBitmap();
            //sourceBmp = sourceBmp.RotateImg(90, Color.Transparent);
            result.Palette = sourceBmp.Palette;
            float rotation = 0;

            foreach ( Tile t in tiles )
            {
                rotation = t.Rotation;
                sourceBmp.CopyRectangleToPoint( t.Rectangle, result, t.Location, source.Palettes[0], t.ReverseX, t.ReverseY );

            }

            return result;
        }