示例#1
0
        private void btnStiToGif_Click(object sender, EventArgs e)
        {
            this.ofd.Filter = "GIF файлы (*.sti)|*.sti";
            if (this.ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (string _stiFileName in this.ofd.FileNames)
                {
                    try
                    {
                        StciData stciData           = new StciData(_stiFileName, 0);
                        List <ExtendedBitmap> _bmps = new List <ExtendedBitmap>();
                        int _foreshorteningIndex    = (int)this.nudForeshorteningIndex.Value;
                        if (stciData._Indexed != null)
                        {
                            ETRLEData data = IndexedConverter.LoadIndexedImageData(stciData);
                            _bmps = IndexedConverter.ConvertEtrleDataToBitmaps(data, _foreshorteningIndex);
                        }
                        else
                        {
                            StringBuilder _sb = new StringBuilder();
                            _sb.AppendLine(String.Format(
                                               "Не индексированный STI-файл {0}, конвертация в GIF невозможна.", _stiFileName));
                            _sb.AppendLine();
                            _sb.AppendLine(String.Format(
                                               "Not indexed STI-file {0}, convertation to STI is denied.", _stiFileName));

                            MessageBox.Show(_sb.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        string _gifFileName = Path.ChangeExtension(_stiFileName, "gif");
                        if (_foreshorteningIndex > 0)
                        {
                            string _fileNameWithoutExtention = Path.GetFileNameWithoutExtension(_stiFileName);
                            string _path = Path.Combine(Path.GetDirectoryName(_stiFileName), _fileNameWithoutExtention);
                            _gifFileName = String.Format("{0}_F_{1}.gif", _path, _foreshorteningIndex);
                        }
                        ushort _delay = (ushort)this.nudDelay.Value;
                        bool   _isTransparentBackground = this.chbTransparentBackground.Checked;
                        GIF.ConvertBitmapsToGif(_bmps, _gifFileName, _delay, _isTransparentBackground, false);
                    }
                    catch (Exception exc)
                    {
                        string        _excMessage = String.Format("{0}\n{1}\n{2}", _stiFileName, exc.Message, exc.StackTrace);
                        ExceptionForm _excForm    = new ExceptionForm(_excMessage);
                        _excForm.ShowDialog();
                        //MessageBox.Show(_excMessage);
                    }
                }
            }
        }
示例#2
0
        void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            List <TreeNode> nodes = new List <TreeNode>();

            fileNames = new List <string>();
            nodes.Add(e.Node);
            makeFileNames(nodes);
            if (fileNames.Count > 0)
            {
                string fileName = fileNames[0];
                if (fileName.EndsWith(".sti", StringComparison.InvariantCultureIgnoreCase))
                {
                    try
                    {
                        StciData stciData        = new StciData(fileName, 0);
                        List <ExtendedBitmap> bm = new List <ExtendedBitmap>();
                        if (stciData._Indexed != null)
                        {
                            ETRLEData data = IndexedConverter.LoadIndexedImageData(stciData);
                            bm = IndexedConverter.ConvertEtrleDataToBitmaps(data, 0);
                        }
                        else
                        {
                            ExtendedBitmap exBm = RGBConverter.GetBitmap(stciData);
                            exBm.ApplicationData = null;
                            bm.Add(exBm);
                        }
                        this.currentSti = bm;
                        this.splitContainer1_Panel2_Paint(this.splitContainer1.Panel2, null);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(String.Format("{3} {0}\n{1}\n{2}",
                                                      fileName, exc.Message, exc.StackTrace, LocalizerNameSpace.Localizer.GetString("LoadingError")));
                    }
                }
            }
        }
示例#3
0
        private List <ExtendedBitmap> getImageList(string fileName, int foreshorting)
        {
            if (fileName.EndsWith(".sti", StringComparison.InvariantCultureIgnoreCase))
            {
                StciData stciData = new StciData(fileName, 0);
                infoData.Add(stciData);
                List <ExtendedBitmap> bm = new List <ExtendedBitmap>();
                if (stciData._Indexed != null)
                {
                    try
                    {
                        ETRLEData data = IndexedConverter.LoadIndexedImageData(stciData);
                        bm = IndexedConverter.ConvertEtrleDataToBitmaps(data, foreshorting);
                        infoEtrleData.Add(data);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(String.Format("{3} {0}/n{1}/n{2}",
                                                      fileName, exc.Message, exc.StackTrace, Resources.GetString("LoadingError")));
                    }
                }
                else
                {
                    ExtendedBitmap exBm = RGBConverter.GetBitmap(stciData);
                    exBm.ApplicationData = null;
                    bm.Add(exBm);
                }
                return(bm);
            }
            else if (fileName.EndsWith(".tif", StringComparison.InvariantCultureIgnoreCase))
            {
                List <Bitmap> bitmaps = TIFF.ConvertTiffToBitmaps(fileName);
                return(bitmaps.ConvertAll <ExtendedBitmap>(
                           delegate(Bitmap bm) { return new ExtendedBitmap(bm, 0, 0); }));
            }
            else if (fileName.EndsWith(".gif", StringComparison.InvariantCultureIgnoreCase))
            {
                List <ExtendedBitmap> result = new List <ExtendedBitmap>();
                try
                {
                    bool containsLocalPalette;
                    result = GIF.ConvertGifToBitmaps(fileName, 0, out containsLocalPalette);
                    if (containsLocalPalette)
                    {
                        MessageBox.Show(Resources.GetString("FileContainsLocaPalettes"),
                                        Resources.GetString("Attention"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message,                     //Resources.GetString("FileContainsLocaPalettes"),
                                    Resources.GetString("Attention"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                return(result);
            }
            else if (fileName.EndsWith(".bmp", StringComparison.InvariantCultureIgnoreCase))
            {
                List <ExtendedBitmap> result = new List <ExtendedBitmap>();
                Bitmap bm = new Bitmap(fileName);
                result.Add(new ExtendedBitmap(bm, 0, 0));
                return(result);
            }
            else if (fileName.EndsWith(".pcx", StringComparison.InvariantCultureIgnoreCase))
            {
                List <ExtendedBitmap> result = new List <ExtendedBitmap>();
                Bitmap bm = new Bitmap(fileName);
                result.Add(new ExtendedBitmap(bm, 0, 0));
                return(result);
            }
            else
            {
                return(null);
            }
        }