private void button1_Click(object sender, EventArgs e) { if (!this.checkBox1.Checked) { foreach (ExtendedBitmap exBm in movie) { if (exBm.ApplicationData == null) { exBm.ApplicationData = new byte[16]; } } int index = 0; index = setAppData(this.numericUpDown1.Value, index); index = setAppData(this.numericUpDown2.Value, index); index = setAppData(this.numericUpDown3.Value, index); index = setAppData(this.numericUpDown4.Value, index); index = setAppData(this.numericUpDown5.Value, index); index = setAppData(this.numericUpDown6.Value, index); index = setAppData(this.numericUpDown7.Value, index); index = setAppData(this.numericUpDown8.Value, index); } this.saveFileDialog1.AddExtension = true; this.saveFileDialog1.DefaultExt = "sti"; this.saveFileDialog1.Filter = this.saveFileDialog1.Filter = "Image Files (*.sti)|*.sti"; if (this.saveFileDialog1.ShowDialog() == DialogResult.OK) { this.Close(); IndexedConverter.ConvertBitmapsToEtrleData(movie, this.saveFileDialog1.FileName); } this.Close(); }
/// <summary> /// Converts the given array into a read-only list, applying the specified conversion to /// each input element. /// </summary> internal static IList <TOutput> ConvertAndMakeReadOnly <TInput, TOutput> (IList <TInput> input, IndexedConverter <TInput, TOutput> converter) { TOutput[] array = new TOutput[input.Count]; for (int i = 0; i < array.Length; i++) { array[i] = converter(input[i], i); } return(new ReadOnlyCollection <TOutput>(array)); }
private void btnGifToSti_Click(object sender, EventArgs e) { this.ofd.Filter = "GIF файлы (*.gif)|*.gif"; if (this.ofd.ShowDialog() == DialogResult.OK) { foreach (string _gifFileName in this.ofd.FileNames) { try { bool _useLocalPalette = false; int _foreshorteningCount = (int)this.nudForeshorteningCount.Value; List <ExtendedBitmap> _bmps = GIF.ConvertGifToBitmaps(_gifFileName, _foreshorteningCount, out _useLocalPalette); if (_foreshorteningCount != 0 && _bmps.Count % _foreshorteningCount != 0) { StringBuilder _sb = new StringBuilder(); _sb.AppendLine(String.Format( "Количество кадров - {0} в файле {1} не делится на количество ракурсов - {2}.", _bmps.Count, _gifFileName, _foreshorteningCount)); _sb.AppendLine(); _sb.AppendLine(String.Format( "Frame number - {0} in file {1} is not devided by foreghortening number - {2}.", _bmps.Count, _gifFileName, _foreshorteningCount)); MessageBox.Show(_sb.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (_useLocalPalette) { StringBuilder _sb = new StringBuilder(); _sb.AppendLine(String.Format( "GIF-файл {0} использует локальные палитры, конвертация в STI невозможна.", _gifFileName)); _sb.AppendLine(); _sb.AppendLine(String.Format( "GIF-file {0} uses local palettes, convertation to STI is denied.", _gifFileName)); MessageBox.Show(_sb.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string _stiFileName = Path.ChangeExtension(_gifFileName, "sti"); IndexedConverter.ConvertBitmapsToEtrleData(_bmps, _stiFileName, this.chbTrim.Checked); } catch (Exception exc) { string _excMessage = String.Format("{0}\n{1}\n{2}", _gifFileName, exc.Message, exc.StackTrace); ExceptionForm _excForm = new ExceptionForm(_excMessage); _excForm.ShowDialog(); //MessageBox.Show(_excMessage); } } } }
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); } } } }
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"))); } } } }
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); } }