예제 #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.ImportBitmap8bpp(currentStream, _fileName);
                }
                else
                {
                    currentSprite.ImportBitmap4bpp(currentStream, _fileName, paletteIndex);
                }

                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
예제 #2
0
        private void ReimportBitmap()
        {
            Sprite currentSprite    = allSpritesEditor1.CurrentSprite;
            int    paletteIndex     = allSpritesEditor1.PaletteIndex;
            bool   importExport8Bpp = allSpritesEditor1.ImportExport8Bpp;

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

                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
예제 #3
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.ImportBitmap8bpp(currentStream, filename);
                }
                else
                {
                    currentSprite.ImportBitmap4bpp(currentStream, filename, paletteIndex);
                }

                allSpritesEditor1.ReloadCurrentSprite();
            }
        }
예제 #4
0
        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)
            {
                if (sprite.Size > 0)
                {
                    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.ImportBitmap8bpp(iso, name);
                        }
                        else
                        {
                            sprite.ImportBitmap4bpp(iso, name, paletteIndex);
                        }

                        imagesProcessed++;
                    }
                    catch (Exception ex)
                    {
                        //MyMessageBox.Show(string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace));      // DEBUG
                    }
                }
                if (progress)
                {
                    progressReporter((100 * (complete++)) / total);
                }
            }

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