// Don't forget to Dispose ImagXpress void Dispose() { if (!(imagXpress1 == null)) { imagXpress1.Dispose(); imagXpress1 = null; } if (!(imagProcessor == null)) { imagProcessor.Dispose(); imagProcessor = null; } if (!(imagX1 == null)) { imagX1.Dispose(); imagX1 = null; } }
public UnlockIXandProcessImg() { try { imagXpress1 = new Accusoft.ImagXpressSdk.ImagXpress(); //***The SetSolutionName, SetSolutionKey and possibly the SetOEMLicenseKey methods must be called to distribute the runtime*** //imagXpress1.Licensing.SetSolutionName("YourSolutionName"); //imagXpress1.Licensing.SetSolutionKey(12345,12345,12345,12345); //imagXpress1.Licensing.SetOEMLicenseKey("1.0.AStringForOEMLicensingContactAccusoftSalesForMoreInformation�"); //System.Console.WriteLine("ImagXpress successfully licensed."); imagProcessor = new Accusoft.ImagXpressSdk.Processor(imagXpress1); soSaveOptions = new Accusoft.ImagXpressSdk.SaveOptions(); soSaveOptions.Format = ImageXFormat.Tiff; soSaveOptions.Tiff.Compression = Compression.Group4; sInputFileName = System.IO.Path.Combine(strCurrentDir, @"..\..\..\..\..\..\..\..\..\..\Common\Images\Benefits.tif"); sOutputFileName = (strCurrentDir + "\\BenefitsRotated.tif"); imagX1 = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, sInputFileName); imagProcessor.Image = imagX1; imagProcessor.Rotate(180); imagX1 = imagProcessor.Image; imagX1.Save(sOutputFileName, soSaveOptions); Dispose(); System.Console.WriteLine(("Rotated TIFF saved to file " + sOutputFileName)); System.Console.ReadLine(); } catch (Accusoft.ImagXpressSdk.ImagXpressException ex) { Dispose(); System.Console.WriteLine(ex.Message); System.Console.WriteLine(ex.Source); System.Console.ReadLine(); } catch (System.Exception ex) { Dispose(); System.Console.WriteLine(ex.Message); System.Console.WriteLine(ex.Source); System.Console.ReadLine(); } }
private void MainForm_Load(object sender, System.EventArgs e) { //***The SetSolutionName, SetSolutionKey and possibly the SetOEMLicenseKey methods must be called to distribute the runtime*** //imagXpress1.Licensing.SetSolutionName("YourSolutionName"); //imagXpress1.Licensing.SetSolutionKey(12345,12345,12345,12345); //imagXpress1.Licensing.SetOEMLicenseKey("1.0.AStringForOEMLicensingContactAccusoftSalesForMoreInformation�"); // Because in this sample the ImageX object is always located in the ImageXView // tell the ImageXView component to dispose of the ImageX object when itself is // disposed. Otherwise, we would have to dispose of the ImageX object in the Form's // Dispose method before the components.Dispose() section. imageXView1.AutoImageDispose = true; imageXView2.AutoImageDispose = true; // turn on AlphaBlend in the view that displays the image with the alpha channel imageXView2.AlphaBlend = true; ixproc1 = new Accusoft.ImagXpressSdk.Processor(imagXpress1); AlphaComboBox.SelectedIndex = 0; String strCurrentDir = System.IO.Path.Combine(Application.StartupPath, @"..\..\..\..\..\..\..\..\..\..\Common\Images\"); if (System.IO.Directory.Exists(strCurrentDir)) { System.IO.Directory.SetCurrentDirectory(strCurrentDir); } strCurrentDir = System.IO.Directory.GetCurrentDirectory(); String strCurrentImage = System.IO.Path.Combine(strCurrentDir, "Alpha1.tif"); imageXView2.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, strCurrentImage); try { String strCurrentAlphaImage = System.IO.Path.Combine(strCurrentDir, "Alpha1.jpg"); imageXView1.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, strCurrentAlphaImage); ixproc1.Image = imageXView1.Image; } catch (Accusoft.ImagXpressSdk.ImagXpressException ex) { SetStatus(ex); } }
private void cmdEmboss_Click(object sender, System.EventArgs e) { // Perform image processing to demonstrate that two ImagXpress controls // are viewing the same image buffer try { Accusoft.ImagXpressSdk.Processor process; process = new Accusoft.ImagXpressSdk.Processor(imagXpress1, imageXViewMain.Image); process.Emboss(); // clear out the error in case there was an error from a previous operation lblError.Text = ""; } catch (Accusoft.ImagXpressSdk.ImagXpressException ex) { AccusoftError(ex, lblError); } catch (System.NullReferenceException ex) { AccusoftError(ex, lblError); } this.Refresh(); }
public void Process() { bool imageOpened = false; int TryCount = 0; while ((!imageOpened) && (TryCount < 25)) { try { //Create the image object and open the image myImage = Accusoft.ImagXpressSdk.ImageX.FromFile(daImagXpress, myImageFileName); imageOpened = true; } catch (ImagXpressException ex) { ChangeLabelText("Error opening image - " + ex.Number.ToString() + ". Retrying..."); } TryCount++; } if (TryCount >= 25) { throw new Exception("Unable to open the image for processing."); } //Rest System.Threading.Thread.Sleep(10); try { //Create the processor object and tie it to the image we just opened myProcessor = new Accusoft.ImagXpressSdk.Processor(daImagXpress, myImage); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); try { //Set the viewer's image object equal to the one we are operating on... //we have to do this each time the image changes because we are making //copies of the image each time ChangeImage(myImage); //Set the viewing zoom type ChangeZoomToFitType(Accusoft.ImagXpressSdk.ZoomToFitType.FitBest); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("Processing..."); //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("Resizing..."); try { //Resize the image myProcessor.Resize(new System.Drawing.Size(myImage.ImageXData.Width * (myResize), myImage.ImageXData.Height * myResize), Accusoft.ImagXpressSdk.ResizeType.Quality); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); try { //Set the viewer's image object equal to the one we are operating on... //we have to do this each time the image changes because we are making //copies of the image each time ChangeImage(myImage); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("Blurring..."); try { //Resize the image myProcessor.Blur(); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); try { //Set the viewer's image object equal to the one we are operating on... //we have to do this each time the image changes because we are making //copies of the image each time ChangeImage(myImage); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("Negating..."); try { //Resize the image myProcessor.Negate(); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); try { //Set the viewer's image object equal to the one we are operating on... //we have to do this each time the image changes because we are making //copies of the image each time ChangeImage(myImage); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("Zooming..."); try { //Set the viewing zoom type ChangeZoomToFitType(Accusoft.ImagXpressSdk.ZoomToFitType.FitWidth); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); try { //Set the viewer's image object equal to the one we are operating on... //we have to do this each time the image changes because we are making //copies of the image each time ChangeImage(myImage); //Set the viewing zoom type ChangeZoomToFitType(Accusoft.ImagXpressSdk.ZoomToFitType.FitBest); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("(Un)Negating..."); try { //Resize the image myProcessor.Negate(); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); try { //Set the viewer's image object equal to the one we are operating on... //we have to do this each time the image changes because we are making //copies of the image each time ChangeImage(myImage); } catch (ImagXpressException ex) { AccusoftError(ex); } //Rest System.Threading.Thread.Sleep(10); //Change the viewer's label. ChangeLabelText("Processed."); //Rest System.Threading.Thread.Sleep(10); //kill the processor myProcessor.Dispose(); myProcessor = null; //kill the local copy of the image myImage.Dispose(); myImage = null; GC.Collect(); System.Threading.Thread.Sleep(100); }