LibInsane  1.0.2
Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library
Functions
normalizers.h File Reference
#include "capi.h"
Include dependency graph for normalizers.h:

Go to the source code of this file.

Functions

enum lis_error lis_api_normalizer_source_nodes (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure that sources are represented as node. More...
 
enum lis_error lis_api_normalizer_min_one_source (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure there is at least one source. More...
 
enum lis_error lis_api_normalizer_all_opts_on_all_sources (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure all options are available on sources. More...
 
enum lis_error lis_api_normalizer_opt_aliases (struct lis_api *to_wrap, struct lis_api **out_impl)
 Make aliases for some options. More...
 
enum lis_error lis_api_normalizer_resolution (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure resolution constraint is always in the same format. More...
 
enum lis_error lis_api_normalizer_source_types (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure source types are clearly identified. More...
 
enum lis_error lis_api_normalizer_bmp2raw (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure the output format is RAW. More...
 
enum lis_error lis_api_normalizer_raw24 (struct lis_api *to_wrap, struct lis_api **out_impl)
 Ensure the output format is RAW24. More...
 
enum lis_error lis_api_normalizer_safe_defaults (struct lis_api *to_wrap, struct lis_api **out_impl)
 Set safest default values. More...
 
enum lis_error lis_api_normalizer_source_names (struct lis_api *to_wrap, struct lis_api **out_impl)
 Makes sure the source names all look the same accross OSes. More...
 
enum lis_error lis_api_normalizer_clean_dev_descs (struct lis_api *to_wrap, struct lis_api **out_impl)
 Clean device descriptors (name, model, etc) More...
 

Function Documentation

◆ lis_api_normalizer_all_opts_on_all_sources()

enum lis_error lis_api_normalizer_all_opts_on_all_sources ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure all options are available on sources.

  • Culprits: Microsoft, Sane project

Goal: Makes sure the application can find easily options by making the scanner options available on all its sources.

Sane: Only the scanner itself has options. Options must all be mapped too on all its sources.

WIA: Some options are on the scanner itself, some options are on the sources. Scanner options must be mapped on all its sources.

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_bmp2raw()

enum lis_error lis_api_normalizer_bmp2raw ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure the output format is RAW.

  • Culprit: Microsoft.

Always getting the image as RAW24 is much more handy if you want to display the scan on-the-fly.

Sane: Image is always returned as RAW (unless some scanner-specific options are set to non-default values).

WIA2: Drivers may return the image in a variety of file formats: RAW, BMP, JPEG, PNG, etc. Not all drivers support returning the image as RAW24. LibInsane supports only BMP and will output the image as RAW24. WIA2 drivers must support the BMP format (Microsoft documentation states that they all must).

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_clean_dev_descs()

enum lis_error lis_api_normalizer_clean_dev_descs ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Clean device descriptors (name, model, etc)

Device model name may contain '_' instead of spaces

Device model name may contain manufacturer name

  • API: Sane, WIA
  • Culprits: too many. Especially HP.

If the model name contains also the manufacturer name, this workaround strips it.

Random example:

  • Manufacturer: Brother
  • Model: Brother MFC-7360N

Will become:

  • Manufacturer: Brother
  • Model: MFC-7360N

Special case: HP. Manufacturer is "hewlett-packard", but model names contain the prefix "hp".

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_min_one_source()

enum lis_error lis_api_normalizer_min_one_source ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure there is at least one source.

  • Culprits: Microsoft, Sane project

Sane: Some scanner do not provide the option "source".

WIA2: Some scanners do not always provide a source. Scan is done directly on them.

If there is no source at all, this normalization will create a fake one.

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_opt_aliases()

enum lis_error lis_api_normalizer_opt_aliases ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Make aliases for some options.

Ensure scan area option names are all the same

Sane: Sane scan area options are used as reference.

WIA2: Fake options are added to simulate Sane options. They act like Sane options, and any change to these options is applied back to the WIA2 options.

Alias 'xres' and 'yres' to 'resolution'

WIA2 provides to options 'xres' and 'yres'. This normalizer will create an alias option 'resolution' that will set both options. 'xres' is used for reading the value.

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_raw24()

enum lis_error lis_api_normalizer_raw24 ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure the output format is RAW24.

  • Culprit: Sane

Sane can return the image as various raw formats: RAW1 (B&W), RAW8 (Grayscale), RAW24 (RGB), etc.

This normalization ensures the output image is always in RAW24 (RGB).

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_resolution()

enum lis_error lis_api_normalizer_resolution ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure resolution constraint is always in the same format.

  • Culprits: Microsoft, Sane project

Sane and WIA: Resolution constraint can be expressed as a range or as a list of possible values. This normalization makes sure they are always expressed as a list. If the range has an interval < 25dpi, the interval used to generate the list will be 25dpi.

Sane: Resolution can be expressed as integers or as SANE_Fixed values (16 bits integer / 16 bits non-integer) (converted as float for the C API)

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_safe_defaults()

enum lis_error lis_api_normalizer_safe_defaults ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Set safest default values.

Ensure most commonly used default values

  • Set mode=Color
  • Set resolution=300 (or the closest resolution available)
  • Set preview=False

Ensure the scan area is set to the maximum by default

By default, some drivers don't have the scan area set to the maximum. This workaround just make sure the default area is the maximum area. It may be handy if you don't want to scan a specific area.

Ensure the scan mode by default is 24bits colors.

By default, some drivers don't have the mode set to color. This workaround just make sure the default mode is 24bits color.

Requires: lis_api_workaround_opt_values

Fujistu: Extra options 'page-height' and 'page-width'

Fujistu provides 2 extra settings, 'page-height' and 'page-width'. 'page-height' use case is unknown, but 'page-width' is used for automatic centering of the page. The default values are bad and this feature is specific to Fujistu ==> set them to the max by default to disable automatic centering.

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_source_names()

enum lis_error lis_api_normalizer_source_names ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Makes sure the source names all look the same accross OSes.

  • All source names will be lower-case
  • No WIA prefix
  • All ADF will be called "feeder"
  • All flatbeds will be called "flatbed"

Exanples when using WIA:

  • '0000\Root\Flatbed' –> 'flatbed'
  • '0000\Root\Feeder' –> 'feeder'

Examples when using Sane:

  • 'Automatic document Feeder (left aligned)' –> 'feeder (left aligned)'
  • 'ADF Duplex' –> 'feeder duplex'
  • 'Flatbed' –> 'flatbed'
  • 'Document Table' –> 'flatbed' (Epson perfection v19)
Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_source_nodes()

enum lis_error lis_api_normalizer_source_nodes ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure that sources are represented as node.

Todo:
TWAIN

WIA2: For each scanner, provides a device tree (see :ref:WIA2 description).

Sane: There is no tree (see :ref:Sane description). Children nodes (sources) are simulated based on the values of the option 'source'.

TWAIN: There is no tree (see :ref:TWAIN description). Children nodes (sources) are simulated based on the values of the option 'feeder_enabled'.

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.

◆ lis_api_normalizer_source_types()

enum lis_error lis_api_normalizer_source_types ( struct lis_api to_wrap,
struct lis_api **  out_impl 
)

Ensure source types are clearly identified.

  • Culprit: Sane project

Sane: Sources have "name", but the exact names are up to the drivers.

WIA2: source types are already clearly defined.

See lis_item::type.

Parameters
[in]to_wrapBase implementation to wrap.
[out]out_implImplementation of the out_impl including the workaround.