PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Document coming from the Twain device
  • Managing the type of image
  • Duplex scanner
  • Multi-page scanner with loader
  • Operating mode in the 64-bit applications
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Allows you to:
  • save the document coming from the Twain device in a GIF file.
  • view the document coming from the Twain device in the user interface of device. The user will have the ability to perform one of the actions proposed by this interface (for example: save the document, modify the default parameters of the device). The available actions depend on the device used.
  • Versions 24 and later
    save the document coming from the Twain device directly in memory in GIF format (in a buffer).
    New in version 24
    save the document coming from the Twain device directly in memory in GIF format (in a buffer).
    save the document coming from the Twain device directly in memory in GIF format (in a buffer).
Example
// Saves the 1st photograph saved in the digital camera
// in the "MyPhoto.GIF" file
// The photo will be saved in black and white
IF TwainToGIF("C:\Temp\MyPhoto.GIF", 256, False, TwainBlackWhite) = True THEN
Info("The photo was saved")
ELSE
Error("The photo was not saved")
END
Versions 24 and later
// Saves the document found in the scanner in memory
// The document will be saved in black and white
IMG_MyImage = TwainToGIF(inMemory, False, TwainBlackWhite)
New in version 24
// Saves the document found in the scanner in memory
// The document will be saved in black and white
IMG_MyImage = TwainToGIF(inMemory, False, TwainBlackWhite)
// Saves the document found in the scanner in memory
// The document will be saved in black and white
IMG_MyImage = TwainToGIF(inMemory, False, TwainBlackWhite)
Syntax

Save and display the document coming from the Twain device in a GIF file Hide the details

<Result> = TwainToGIF([<GIF file> [, <Number of image colors> [, <User interface> [, <Type of image> [, <Number of bits per pixel> [, <Image resolution> [, <Image contrast> [, <Image brightness> [, <Duplex mode> [, <Automatic load>]]]]]]]]]])
<Result>: Boolean
  • True if the document was saved or viewed,
  • False if the document was not saved. The corresponding error message is returned by ErrorInfo.
<GIF file>: Optional character string
Name and full (or relative) path of file (up to 260 characters). The file extension is optional. A UNC path can be used.
If this parameter is not specified or if it corresponds to an empty string (""), the user will have to enter the full name of the GIF file in a file picker.
<Number of image colors>: Optional integer
Number of colors proposed in the color palette when using the GIF file (value included between 16 and 256).
If this parameter is not specified, the number of proposed colors will be equal to 256.
<User interface>: Optional boolean
  • True (default value) if the user interface of the Twain device must be displayed. When saving a document, the <GIF file> will be proposed by default
  • False if the user interface of the Twain device must not be displayed.
<Type of image>: Optional Integer constant (or combination of constants)
Type of image used to save the document (classified by order of color management):
Order for managing the colors
0 (Default value)Default image of device.
1TwainPaletteColored image issued from a palette.
2TwainRGBRGB image.
3TwainGrayScaleGrayscale image.
4TwainBlackWhiteImage in black and white.
-TwainAnyTypeAny type of image.

If these constants are combined, the best type of image supported by the device will be selected (according to the order of color management). See remarks for more details.
The default type of image will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified type of image is not supported by the device.
  • if <User interface> is set to True.
<Number of bits per pixel>: Optional integer
Amount of information about the colors (to display or print each pixel in an image). The larger the number of bits per pixel, the sharper the color rendering will be.
The possible values for this parameter depend on the type of image used:
Type of imagePossible values
Colored image issued from a palette (TwainPalette constant).1, 4 or 8
RGB image (TwainRGB constant).8, 10 or 16
Grayscale image (TwainGrayScale constant).8 or 16
Image in black and white (TwainBlackWhite constant).1

If this parameter is not specified, the default number of bits per pixel will be used.
<Image resolution>: Optional real
Number of pixels per inch (the possible values depend on the device used).
The default image resolution will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified resolution is not supported by the device.
  • if <User interface> is set to True.
<Image contrast>: Optional real
Contrast of the image (value included between -1000 and 1000).
The default image contrast will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified contrast is not supported by the device.
  • if <User interface> is set to True.
<Image brightness>: Optional real
Brightness of the image (value included between -1000 and 1000).
The default image brightness will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified brightness is not supported by the device.
  • if <User interface> is set to True.
<Duplex mode>: Optional boolean
  • True to scan a document on both sides,
  • False (by default) to scan the document on a single side.
<Automatic load>: Optional boolean
Versions 15 and later
  • True to automatically load the pages in the device,
  • False otherwise.
New in version 15
  • True to automatically load the pages in the device,
  • False otherwise.
  • True to automatically load the pages in the device,
  • False otherwise.
Versions 24 and later

Saving the document from the Twain device in memory in GIF format Hide the details

<Result> = TwainToGIF(<InMemory> [, <Number of image colors> [, <User interface> [, <Type of image> [, <Number of bits per pixel> [, <Image resolution> [, <Image contrast> [, <Image brightness> [, <Duplex Mode> [, <Automatic load>]]]]]]]]])
<Result>: Buffer
Byte string containing the document in GIF format.
Then this byte string can be assigned to an Image control, saved in a file (fSaveText), sent via a network (with the Socket functions), etc.
<InMemory>: Constant
inMemorySaves the document from the Twain device in memory.
<Number of image colors>: Optional integer
Number of colors proposed in the color palette when using the GIF file (value included between 16 and 256).
If this parameter is not specified, the number of proposed colors will be equal to 256.
<User interface>: Optional boolean
  • True (default value) if the user interface of the Twain device must be displayed.
  • False if the user interface of the Twain device must not be displayed.
<Type of image>: Optional Integer constant (or combination of constants)
Type of image used to save the document (classified by order of color management):
Order for managing the colors
0 (Default value)Default image of device.
1TwainPaletteColored image issued from a palette.
2TwainRGBRGB image.
3TwainGrayScaleGrayscale image.
4TwainBlackWhiteImage in black and white.
-TwainAnyTypeAny type of image.

If these constants are combined, the best type of image supported by the device will be selected (according to the order of color management). See remarks for more details.
The default type of image will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified type of image is not supported by the device.
  • if <User interface> is set to True.
<Number of bits per pixel>: Optional integer
Amount of information about the colors (to display or print each pixel in an image). The larger the number of bits per pixel, the sharper the color rendering will be.
The possible values for this parameter depend on the type of image used:
Type of imagePossible values
Colored image issued from a palette (TwainPalette constant).1, 4 or 8
RGB image (TwainRGB constant).8, 10 or 16
Grayscale image (TwainGrayScale constant).8 or 16
Image in black and white (TwainBlackWhite constant).1

If this parameter is not specified, the default number of bits per pixel will be used.
<Image resolution>: Optional real
Number of pixels per inch (the possible values depend on the device used).
The default image resolution will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified resolution is not supported by the device.
  • if <User interface> is set to True.
<Image contrast>: Optional real
Contrast of the image (value included between -1000 and 1000).
The default image contrast will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified contrast is not supported by the device.
  • if <User interface> is set to True.
<Image brightness>: Optional real
Brightness of the image (value included between -1000 and 1000).
The default image brightness will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified brightness is not supported by the device.
  • if <User interface> is set to True.
<Duplex Mode>: Optional boolean
  • True to scan a document on both sides,
  • False (by default) to scan the document on a single side.
<Automatic load>: Optional boolean
Versions 15 and later
  • True to automatically load the pages in the device,
  • False otherwise.
New in version 15
  • True to automatically load the pages in the device,
  • False otherwise.
  • True to automatically load the pages in the device,
  • False otherwise.
New in version 24

Saving the document from the Twain device in memory in GIF format Hide the details

<Result> = TwainToGIF(<InMemory> [, <Number of image colors> [, <User interface> [, <Type of image> [, <Number of bits per pixel> [, <Image resolution> [, <Image contrast> [, <Image brightness> [, <Duplex Mode> [, <Automatic load>]]]]]]]]])
<Result>: Buffer
Byte string containing the document in GIF format.
Then this byte string can be assigned to an Image control, saved in a file (fSaveText), sent via a network (with the Socket functions), etc.
<InMemory>: Constant
inMemorySaves the document from the Twain device in memory.
<Number of image colors>: Optional integer
Number of colors proposed in the color palette when using the GIF file (value included between 16 and 256).
If this parameter is not specified, the number of proposed colors will be equal to 256.
<User interface>: Optional boolean
  • True (default value) if the user interface of the Twain device must be displayed.
  • False if the user interface of the Twain device must not be displayed.
<Type of image>: Optional Integer constant (or combination of constants)
Type of image used to save the document (classified by order of color management):
Order for managing the colors
0 (Default value)Default image of device.
1TwainPaletteColored image issued from a palette.
2TwainRGBRGB image.
3TwainGrayScaleGrayscale image.
4TwainBlackWhiteImage in black and white.
-TwainAnyTypeAny type of image.

If these constants are combined, the best type of image supported by the device will be selected (according to the order of color management). See remarks for more details.
The default type of image will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified type of image is not supported by the device.
  • if <User interface> is set to True.
<Number of bits per pixel>: Optional integer
Amount of information about the colors (to display or print each pixel in an image). The larger the number of bits per pixel, the sharper the color rendering will be.
The possible values for this parameter depend on the type of image used:
Type of imagePossible values
Colored image issued from a palette (TwainPalette constant).1, 4 or 8
RGB image (TwainRGB constant).8, 10 or 16
Grayscale image (TwainGrayScale constant).8 or 16
Image in black and white (TwainBlackWhite constant).1

If this parameter is not specified, the default number of bits per pixel will be used.
<Image resolution>: Optional real
Number of pixels per inch (the possible values depend on the device used).
The default image resolution will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified resolution is not supported by the device.
  • if <User interface> is set to True.
<Image contrast>: Optional real
Contrast of the image (value included between -1000 and 1000).
The default image contrast will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified contrast is not supported by the device.
  • if <User interface> is set to True.
<Image brightness>: Optional real
Brightness of the image (value included between -1000 and 1000).
The default image brightness will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified brightness is not supported by the device.
  • if <User interface> is set to True.
<Duplex Mode>: Optional boolean
  • True to scan a document on both sides,
  • False (by default) to scan the document on a single side.
<Automatic load>: Optional boolean
Versions 15 and later
  • True to automatically load the pages in the device,
  • False otherwise.
New in version 15
  • True to automatically load the pages in the device,
  • False otherwise.
  • True to automatically load the pages in the device,
  • False otherwise.

Saving the document from the Twain device in memory in GIF format Hide the details

<Result> = TwainToGIF(<InMemory> [, <Number of image colors> [, <User interface> [, <Type of image> [, <Number of bits per pixel> [, <Image resolution> [, <Image contrast> [, <Image brightness> [, <Duplex Mode> [, <Automatic load>]]]]]]]]])
<Result>: Buffer
Byte string containing the document in GIF format.
Then this byte string can be assigned to an Image control, saved in a file (fSaveText), sent via a network (with the Socket functions), etc.
<InMemory>: Constant
inMemorySaves the document from the Twain device in memory.
<Number of image colors>: Optional integer
Number of colors proposed in the color palette when using the GIF file (value included between 16 and 256).
If this parameter is not specified, the number of proposed colors will be equal to 256.
<User interface>: Optional boolean
  • True (default value) if the user interface of the Twain device must be displayed.
  • False if the user interface of the Twain device must not be displayed.
<Type of image>: Optional Integer constant (or combination of constants)
Type of image used to save the document (classified by order of color management):
Order for managing the colors
0 (Default value)Default image of device.
1TwainPaletteColored image issued from a palette.
2TwainRGBRGB image.
3TwainGrayScaleGrayscale image.
4TwainBlackWhiteImage in black and white.
-TwainAnyTypeAny type of image.

If these constants are combined, the best type of image supported by the device will be selected (according to the order of color management). See remarks for more details.
The default type of image will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified type of image is not supported by the device.
  • if <User interface> is set to True.
<Number of bits per pixel>: Optional integer
Amount of information about the colors (to display or print each pixel in an image). The larger the number of bits per pixel, the sharper the color rendering will be.
The possible values for this parameter depend on the type of image used:
Type of imagePossible values
Colored image issued from a palette (TwainPalette constant).1, 4 or 8
RGB image (TwainRGB constant).8, 10 or 16
Grayscale image (TwainGrayScale constant).8 or 16
Image in black and white (TwainBlackWhite constant).1

If this parameter is not specified, the default number of bits per pixel will be used.
<Image resolution>: Optional real
Number of pixels per inch (the possible values depend on the device used).
The default image resolution will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified resolution is not supported by the device.
  • if <User interface> is set to True.
<Image contrast>: Optional real
Contrast of the image (value included between -1000 and 1000).
The default image contrast will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified contrast is not supported by the device.
  • if <User interface> is set to True.
<Image brightness>: Optional real
Brightness of the image (value included between -1000 and 1000).
The default image brightness will be used:
  • if this parameter is not specified or if it corresponds to 0.
  • if the specified brightness is not supported by the device.
  • if <User interface> is set to True.
<Duplex Mode>: Optional boolean
  • True to scan a document on both sides,
  • False (by default) to scan the document on a single side.
<Automatic load>: Optional boolean
Versions 15 and later
  • True to automatically load the pages in the device,
  • False otherwise.
New in version 15
  • True to automatically load the pages in the device,
  • False otherwise.
  • True to automatically load the pages in the device,
  • False otherwise.
Remarks

Document coming from the Twain device

The "document coming from the Twain device" corresponds to:
  • the document found in a scanner during the call to TwainToGIF. In this case, the parameters specified in TwainScanZone are taken into account.
  • the image broadcasted by a "web camera" during the call to TwainToGIF.
  • the first photo saved in a digital camera.
    Note: If the user interface is used, the retrieved document will correspond to the photo selected by the user. If several photos are selected, only the first selected photo will be retrieved.

Managing the type of image

If several constants are combined in <Type of image>, the best type of image supported by the device will be selected (according to the order of color management).
For example: If this parameter corresponds to TwainBlackWhite + TwainRGB, the type of the image will be:
  • RGB if this type is supported by the device.
  • black and white otherwise.

Duplex scanner

If the scanner supports the duplex mode, you have the ability to perform a double-sided scan. The generated document contains both sides of the scanned document.
Note: Depending on the hardware used, the Twain driver may not be sufficient to support a double-sided scan. You may have to install additional drivers supplied by the manufacturer.

Multi-page scanner with loader

If the scanner includes a loader and if it supports the multi-pages, you have the ability to perform a scan of all the pages in a row.
See TwainState for more details.

Operating mode in the 64-bit applications

In a 64-bit application, this function will automatically use the 64-bit Twain driver. The TWAIN cannot be used if this driver is not installed.
Component : wd240std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment