Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 // 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;
     }
 }
Пример #4
0
        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();
            }
        }
Пример #5
0
        static private Accusoft.ImagXpressSdk.ImageX StreamInFile(System.String sFilename, Accusoft.ImagXpressSdk.LoadOptions oOpts, ImagXpress imagXpress1)
        {
            System.Int32 iFileLength;

            System.IO.FileStream fsReader = new System.IO.FileStream(sFilename, System.IO.FileMode.Open);
            iFileLength = Convert.ToInt32(fsReader.Length);
            if (iFileLength < 0)
            {
                iFileLength = 0;
                fsReader.Close();
                return(null);
            }
            else
            {
                Accusoft.ImagXpressSdk.ImageX returnImageX = Accusoft.ImagXpressSdk.ImageX.FromStream(imagXpress1, fsReader, oOpts);
                fsReader.Close();
                return(returnImageX);
            }
        }
Пример #6
0
 private void LoadFile()
 {
     try
     {
         if (imageXView1.Image != null)
         {
             imageXView1.Image.Dispose();
         }
         imagX1 = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, imgFileName);
         if ((imagX1.ImageXData.BitsPerPixel != 24))
         {
             MessageBox.Show("Image must be 24-bit for sample methods. Converting image to 24-bit.");
             processor1.Image = imagX1;
             processor1.ColorDepth(24, PaletteType.Fixed, DitherType.NoDither);
         }
         imageXView1.Image = imagX1;
         // clear out the error in case there was an error from a previous operation
         lblError.Text = "";
     }
     catch (Accusoft.ImagXpressSdk.ImagXpressException ex)
     {
         AccusoftError(ex, lblError);
     }
 }
Пример #7
0
        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);
        }
Пример #8
0
 private void ChangeImage(Accusoft.ImagXpressSdk.ImageX newImage)
 {
     object[] theArgs = { newImage.Copy() };
     myReferenceToMyViewer.Invoke(new SafeContextImageChanger(this.RealImageChangerInTheSafeContext), theArgs);
 }