How to check image formats supported by scanner?
I would like to get file formats supported by scanner via TWAIN interface. There is an example how to get supported formats:
GetCapability(ICAP_IMAGEFILEFORMAT, unTest);
CString strType;
strType.Format("Type Supported %d\n", unTest);
But I guess there is something wrong here because ICAP_IMAGEFILEFORMAT members not a bit masks:
#define TWFF_TIFF 0 /* Tagged Image File开发者_StackOverflow Format */
#define TWFF_PICT 1 /* Macintosh PICT */
#define TWFF_BMP 2 /* Windows Bitmap */
#define TWFF_XBM 3
#define TWFF_JFIF 4 /* JPEG File Interchange Format */
#define TWFF_FPX 5 /* Flash Pix */
...
So if scanner supports TIFF, PICT, BMP & JFIF it's impossible to return such informartion within one call.
How can I get list of supported formats by scanner?
I believe you'll have to query the DS (e.g. try setting the value you want) to see if the format you want is supported, then based on results you could build the list or supported formats. I think this is the way as the msgget container is,
TW_ONEVALUE -- A single value whose current and default values are coincident. The range of available values for this type of capability is simply this single value. For example, a capability that indicates the presence of a document feeder could be of this type.
and the description from ICAP_IMAGEFILEFORMAT section of the spec seems to imply that you'd only be able to set to a single value, or get back a single value:
Application
Use this ICAP to determine which formats are available for file transfers, and set the context for other capability negotiations such as ICAP_COMPRESSION. Be sure to use the DG_CONTROL / DAT_SETUPFILEXFER / MSG_SET operation to specify the format to be used for a particular acquisition.
Source
If not supported, return TWRC_FAILURE / TWCC_CAPUNSUPPORTED. If Operation is not supported, return TWRC_FAILURE, TWCC_CAPBADOPERATION. (See DG_CONTROL /DAT_CAPABILITY/ MSG_QUERYSUPPORT)
Anyway, I could be mis-interpreting, but that's what it seems like to me.
I think getting all the supported file formats in one call is doable, since both "Container for MSG_GET" and "Container for MSG_SET" support TW_ENUMERATION.
精彩评论