private static void DisposeOfProcessorImage(ImageX procImage) { if (procImage != null) { procImage.Dispose(); procImage = null; } }
public void ConvertTIFtoMultiPage(FileInfo mCaminhoOrigem, FileInfo mCaminhoDestino, string mTipo) { try { using (ImagXpress _imageX10 = new ImagXpress()) { _imageX10.Licensing.UnlockRuntime(1908225079, 373669040, 1341647942, 30454); ImageX image = ImageX.FromFile(_imageX10, mCaminhoOrigem.FullName); try { SaveOptions so = new SaveOptions(); so.Format = ImageXFormat.Tiff; if (mTipo.ToUpper() == "PDF") { so.Format = ImageXFormat.Pdf; } so.Tiff.MultiPage = true; so.Pdf.MultiPage = true; if (image.BitsPerPixel != 1) { so.Tiff.Compression = Compression.Jpeg; so.Pdf.Compression = Compression.Jpeg; } else { so.Tiff.Compression = Compression.Group4; so.Pdf.Compression = Compression.Group4; } image.Save(mCaminhoDestino.FullName, so); } catch { throw; } finally { image.Dispose(); } } } catch (Exception exp) { throw new Exception("Erro ao processar imagem:\t" + exp.Message + Environment.NewLine + exp.StackTrace); } }
protected override bool PerformProcessingAction() { Processor proc = null; ImageX sourceImage = null; try { if (String.IsNullOrEmpty(SourceImageTextBox.Text)) { Helper.ShowBalloonToolTipWarning( SourceImageTextBox.Width - Constants.balloonToolTipHorizontalSpacer, -Constants.balloonToolTipVerticalSpacer, Constants.tooltipInitialDelay, Constants.tooltipDuration, Constants.mergeString, Constants.mergeErrorString, SourceImageTextBox); this.DialogResult = DialogResult.None; return(false); } else { proc = new Processor(imagXpress1, imageXView1.Image.Copy()); Helper.TransformIfGrayscale(proc.Image); Point currentScrollPosition; if (imageXView2.Image == null) { currentScrollPosition = imageXView1.ScrollPosition; } else { currentScrollPosition = imageXView2.ScrollPosition; } sourceImage = ImageX.FromFile(imagXpress1, SourceImageTextBox.Text); proc.Merge(ref sourceImage, (MergeSize)MergeSizeComboBox.SelectedIndex, (MergeStyle)MergeStyleComboBox.SelectedIndex, TransparentCheckBox.Checked, TransparentColorButton.BackColor, (int)MergePercentHighNumericUpDown.Value, (int)MergePercentLowNumericUpDown.Value); UpdateOutputImage(proc.Image.Copy()); imageXView2.ScrollPosition = currentScrollPosition; return(true); } } catch (ProcessorException ex) { MessageBox.Show(ex.Message, Constants.processingErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } catch (ImageXException ex) { MessageBox.Show(ex.Message, Constants.processingErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } finally { if (sourceImage != null) { sourceImage.Dispose(); sourceImage = null; } if (proc != null) { if (proc.Image != null) { proc.Image.Dispose(); proc.Image = null; } proc.Dispose(); proc = null; } } }