Exemple #1
0
        private void ImportBitmap()
        {
            Sprite currentSprite    = allSpritesEditor1.CurrentSprite;
            int    paletteIndex     = allSpritesEditor1.PaletteIndex;
            bool   importExport8Bpp = allSpritesEditor1.ImportExport8Bpp;

            openFileDialog.Filter          = importExport8Bpp ? "8bpp paletted bitmap (*.BMP)|*.bmp" : "4bpp paletted bitmap (*.BMP)|*.bmp";
            openFileDialog.FileName        = string.Empty;
            openFileDialog.CheckFileExists = true;
            if (currentSprite != null && openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                _fileName = openFileDialog.FileName; // R999

                if (importExport8Bpp)
                {
                    currentSprite.ImportBitmap(currentStream, _fileName);
                }
                else
                {
                    currentSprite.ImportBitmap4bpp(currentStream, _fileName, paletteIndex);
                }

                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
Exemple #2
0
        // R999
        private void reimportMenuItem_Click(object sender, EventArgs e)
        {
            Sprite currentSprite = allSpritesEditor1.CurrentSprite;

            if (_fileName != null && currentSprite != null)
            {
                currentSprite.ImportBitmap(currentStream, _fileName);
                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
Exemple #3
0
 // R999 reimportButton keypress event handler
 private void reimportButtonKeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar.Equals('r'))
     {
         Sprite currentSprite = allSpritesEditor1.CurrentSprite;
         if (_fileName != null && currentSprite != null)
         {
             currentSprite.ImportBitmap(currentStream, _fileName);
             allSpritesEditor1.ReloadCurrentSprite();
         }
     }
 }
Exemple #4
0
        private void importBmpMenuItem_Click(object sender, EventArgs e)
        {
            Sprite currentSprite = allSpritesEditor1.CurrentSprite;

            openFileDialog.Filter          = "8bpp paletted bitmap (*.BMP)|*.bmp";
            openFileDialog.FileName        = string.Empty;
            openFileDialog.CheckFileExists = true;
            if (currentSprite != null && openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                _fileName = openFileDialog.FileName;                 // R999
                currentSprite.ImportBitmap(currentStream, openFileDialog.FileName);
                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
Exemple #5
0
        private void ReimportBitmap()
        {
            Sprite currentSprite    = allSpritesEditor1.CurrentSprite;
            int    paletteIndex     = allSpritesEditor1.PaletteIndex;
            bool   importExport8Bpp = allSpritesEditor1.ImportExport8Bpp;

            if (_fileName != null && currentSprite != null)
            {
                if (importExport8Bpp)
                {
                    currentSprite.ImportBitmap(currentStream, _fileName);
                }
                else
                {
                    currentSprite.ImportBitmap4bpp(currentStream, _fileName, paletteIndex);
                }

                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
Exemple #6
0
        private void ImportBitmap(string filename)
        {
            Sprite currentSprite    = allSpritesEditor1.CurrentSprite;
            int    paletteIndex     = allSpritesEditor1.PaletteIndex;
            bool   importExport8Bpp = allSpritesEditor1.ImportExport8Bpp;

            if ((currentSprite != null) && (File.Exists(filename)))
            {
                _fileName = filename; // R999

                if (importExport8Bpp)
                {
                    currentSprite.ImportBitmap(currentStream, filename);
                }
                else
                {
                    currentSprite.ImportBitmap4bpp(currentStream, filename, paletteIndex);
                }

                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
        private AllSpritesDoWorkResult LoadAllSprites(Stream iso, string path, bool importExport8bpp, int paletteIndex, Action <int> progressReporter)
        {
            bool progress        = progressReporter != null;
            int  total           = 0;
            int  complete        = 0;
            int  imagesProcessed = 0;

            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;
                }
            }

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

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

                string name = Path.Combine(path, singleFileMap.Key);
                if (File.Exists(name))
                {
                    Sprite sprite = singleFileMap.Value;

                    try
                    {
                        if (importExport8bpp)
                        {
                            sprite.ImportBitmap(iso, name);
                        }
                        else
                        {
                            sprite.ImportBitmap4bpp(iso, name, paletteIndex);
                        }

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

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