Accusoft.TwainPro9.Net
Pass Image Data between Accusoft Components

Traditionally, transferring image data between Accusoft components has required passing the image data in a DIB format. But, beginning with the release of ImagXpress 11, we are adding new methods throughout our products which allow you to easily copy or transfer image data between different Accusoft objects with just a single method call.

Regardless of its product or component assembly, any Accusoft image class which supports easily sending its image data to another Accusoft object will implement two methods: CopyTo(object destination) and TransferTo(object destination). And any Accusoft image class which supports easily receiving this image data (that is, being the destination object) will be noted in its class documentation.

A CopyTo method makes a complete copy of the image data. When called, both the source and destination objects will contain their own separate copies of identical image data. A TransferTo method, on the other hand, completely transfers the image data from one object to another. When finished, the source object will no longer contain image data; the image will be owned by the destination object.

Within the ImagXpress Suite

Within the ImagXpress suite of components, there are four classes which support sending their image data via CopyTo and TransferTo methods:

  1. ImagXpress - Accusoft.ImagXpressSdk.ImageX
  2. TwainPRO - Accusoft.TwainProSdk.ScannedImage
  3. ISIS Xpress - Accusoft.ISISXpressSdk.Output
  4. ThumbnailXpress - Accusoft.ThumbnailXpressSdk.ThumbnailItem

And within the ImagXpress suite of components, there is only one class which supports receiving image data: the ImagXpress ImageX class.

Other Accusoft products may contain additional classes which can send and receive image data.

How to Transfer Image Data from TwainPRO to ImagXpress

Here's an example that scans an image with TwainPRO and then transfers the image data to ImagXpress for further processing before being saved.

C# Example
Copy Code
using Accusoft.ImagXpressSdk; using Accusoft.TwainProSdk;

namespace ConsoleExample
{
    class Program
    {
        static void Main(string[] args)
        {
            using (TwainPro twainPro = new TwainPro())
            using (TwainDevice twainDevice = new TwainDevice(twainPro))
            {
                twainDevice.Scanned += new ScannedEventHandler(twainDevice_Scanned);
                twainDevice.SelectSource();
                twainDevice.StartSession();
            }
        }

        static void twainDevice_Scanned(object sender, ScannedEventArgs e)
        {
            using (ImagXpress ix = new ImagXpress())
            using (ImageX image = new ImageX(ix))
            using (Processor processor = new Processor(ix))
            {
                //Transfer the scanned image data from TwainPRO to ImagXpress
                e.ScannedImage.TransferTo(image);

                //Process and save the image with ImagXpress
                processor.Image = image;
                processor.Negate();
                image.Save("inverted-scan.bmp");
            }
        }
    }
}

In the above example, we transfer the scanned image to an ImagXpress ImageX object named image. Once that is done, we can use any of the processing features of ImagXpress to manipulate the scanned image data. In this case we simply create a color negative of the image data and then save it to disk as "inverted-scan.bmp".

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback