Pass Image Data Between Different 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 ScanFix Xpress 7, new methods were added 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 ScanFix Xpress
Within the ScanFix Xpress component, there is a class which supports sending and/or receiving its image data via CopyTo and TransferTo methods. It is the ScanFix class.
Other Accusoft products may contain additional classes which can send and receive image data.
How to Transfer Image Data from One ScanFix Object to Another
You can use this new approach to easily copy or transfer image data from a ScanFix object to objects of other Accusoft components.
Here's an example for transferring between a ScanFix and an ImageX object from the ImagXpress component.
C# Example |
Copy Code |
using System.Drawing;
using Accusoft.ScanFixXpressSdk;
namespace ConsoleExample
{
class Program
{
static void Main(string[] args)
{
using (ImagXpress ix = new ImagXpress())
using (imageX ixImage = new ImageX(ix, 400, 400, 24, Color.Red))
using (ScanFix sx = new ScanFix())
{
ixImage.Save("original.bmp");
ixImage.TransferTo(sx);
sx.AutoBinarize();
sx.TransferTo(ixImage);
ixImage.Save("binarized.bmp");
}
}
}
} |
In the above example, we create a small, 24-bit red image object named ixImage and save its image data to disk as "original.bmp". If you open this file, you will see a small red image.
Then, we transfer its image data to the sx object, perform an automatic binarization operation using sx, transfer data back to ixImage, and then save it as "binarized.bmp". Since the image data inside the sx object was completely transferred to the ixImage object, if you open this second file you will see a binarized version of the original image.