private void _btnSave_Click(object sender, EventArgs e) { if (_lstSelectedImages.Items.Count == 0) { Messager.ShowError(this, "Please select images to save"); return; } Jpeg2000FileFormat format = (Path.GetExtension(_txtFileName.Text) == ".jp2") ? Jpeg2000FileFormat.LeadJp2 : Jpeg2000FileFormat.LeadJpx; RasterImage saveImage = ((ListItem)_lstSelectedImages.Items[0]).Image.CloneAll(); for (int index = 1; index < _lstSelectedImages.Items.Count; index++) { saveImage.AddPage(((ListItem)_lstSelectedImages.Items[index]).Image.CloneAll()); } try { _mainForm.Jpeg2000Eng.Save(_mainForm.Codecs, _txtFileName.Text, saveImage, format, Convert.ToInt32(_cbBPP.SelectedItem), Convert.ToInt32(_cbQualityFactor.SelectedIndex)); DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { Messager.ShowError(this, ex); } }
private void _btnSave_Click(object sender, EventArgs e) { if (_lstColorImages.Items.Count == 0) { Messager.ShowError(this, "Please select images to save"); return; } Jpeg2000FileFormat format = (Path.GetExtension(_txtFileName.Text) == ".jp2") ? Jpeg2000FileFormat.LeadJp2 : Jpeg2000FileFormat.LeadJpx; List <CompositeJpxImages> saveCompositeImage = new List <CompositeJpxImages>(); CompositeJpxImages itemImage; ListItem item; for (int index = 0; index < _lstColorImages.Items.Count; index++) { itemImage = new CompositeJpxImages(); item = (ListItem)_lstColorImages.Items[index]; itemImage.ColorImage = item.Image.CloneAll(); item = (ListItem)_lstOpacityImages.Items[index]; if (item.Name == "*") { itemImage.OpacityImage = null; } else { itemImage.OpacityImage = item.Image.CloneAll(); } item = (ListItem)_lstPreOpacityImages.Items[index]; if (item.Name == "*") { itemImage.PreOpacityImage = null; } else { itemImage.PreOpacityImage = item.Image.CloneAll(); } saveCompositeImage.Add(itemImage); } try { if (IsComposite) { _mainForm.Jpeg2000Eng.SaveComposite(_mainForm.Codecs, _txtFileName.Text, saveCompositeImage, format, Convert.ToInt32(_cbBPP.SelectedItem), Convert.ToInt32(_cbQualityFactor.SelectedIndex)); } else { _mainForm.Jpeg2000Eng.AppendFrames(_mainForm.Codecs, _txtFileName.Text, saveCompositeImage, Convert.ToInt32(_cbBPP.SelectedItem), Convert.ToInt32(_cbQualityFactor.SelectedIndex)); } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { Messager.ShowError(this, ex); } }