private void BlendButton_Click(object sender, System.EventArgs e) { try { ResetStatus(); Accusoft.ImagXpressSdk.ImageX alphaImage = imageXView2.Image.Copy(); // Set an arbitrary location to merge the image into PointF pt = GetAlphaImageLocation( ); SizeF size = new SizeF(alphaImage.ImageXData.Width, alphaImage.ImageXData.Height); ixproc1.SetArea(new RectangleF(pt, size)); ixproc1.EnableArea = true; ixproc1.Merge(ref alphaImage, Accusoft.ImagXpressSdk.MergeSize.Crop, Accusoft.ImagXpressSdk.MergeStyle.AlphaForeGroundOverBackGround, false, System.Drawing.Color.Blue, 90, 90); if (alphaImage != null) { alphaImage.Dispose(); alphaImage = null; } ixproc1.EnableArea = false; SetStatus("Image successfully blended!"); } catch (Accusoft.ImagXpressSdk.ImagXpressException ex) { SetStatus(ex); } }
private void RealImageChangerInTheSafeContext(Accusoft.ImagXpressSdk.ImageX newImage) { Accusoft.ImagXpressSdk.ImageX oldImage = myReferenceToMyViewer.Image; myReferenceToMyViewer.Image = newImage; if (oldImage != null) { oldImage.Dispose(); oldImage = null; } GC.Collect(); System.Threading.Thread.Sleep(25); }
// 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 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); }