2 * Copyright 2000 Corel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define NONAMELESSUNION
20 #define NONAMELESSSTRUCT
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(twain
);
32 TW_UINT16
TWAIN_SaneCapability (activeDS
*pSource
, pTW_CAPABILITY pCapability
,
35 TW_UINT16 twCC
= TWCC_SUCCESS
;
37 TRACE("capability=%d action=%d\n", pCapability
->Cap
, action
);
39 switch (pCapability
->Cap
)
44 case ACAP_AUDIOFILEFORMAT
:
46 case ICAP_AUTOMATICBORDERDETECTION
:
47 case ICAP_AUTOMATICDESKEW
:
48 case ICAP_AUTODISCARDBLANKPAGES
:
49 case ICAP_AUTOMATICROTATE
:
50 case ICAP_FLIPROTATION
:
51 case CAP_AUTOMATICCAPTURE
:
52 case CAP_TIMEBEFOREFIRSTCAPTURE
:
53 case CAP_TIMEBETWEENCAPTURES
:
55 case CAP_CLEARBUFFERS
:
56 case CAP_MAXBATCHBUFFERS
:
57 case ICAP_BARCODEDETECTIONENABLED
:
58 case ICAP_SUPPORTEDBARCODETYPES
:
59 case ICAP_BARCODEMAXSEARCHPRIORITIES
:
60 case ICAP_BARCODESEARCHPRIORITIES
:
61 case ICAP_BARCODESEARCHMODE
:
62 case ICAP_BARCODEMAXRETRIES
:
63 case ICAP_BARCODETIMEOUT
:
64 case CAP_EXTENDEDCAPS
:
65 case CAP_SUPPORTEDCAPS
:
68 case ICAP_PLANARCHUNKY
:
69 case ICAP_BITORDERCODES
:
70 case ICAP_CCITTKFACTOR
:
71 case ICAP_COMPRESSION
:
72 case ICAP_JPEGPIXELTYPE
:
73 /*case ICAP_JPEGQUALITY:*/
74 case ICAP_PIXELFLAVORCODES
:
76 case CAP_DEVICEONLINE
:
77 case CAP_DEVICETIMEDATE
:
78 case CAP_SERIALNUMBER
:
79 case ICAP_EXPOSURETIME
:
81 case ICAP_IMAGEFILTER
:
84 case ICAP_NOISEFILTER
:
86 case ICAP_PHYSICALHEIGHT
:
87 case ICAP_PHYSICALWIDTH
:
91 case CAP_PRINTERENABLED
:
92 case CAP_PRINTERINDEX
:
94 case CAP_PRINTERSTRING
:
95 case CAP_PRINTERSUFFIX
:
100 case ICAP_BRIGHTNESS
:
103 case ICAP_ORIENTATION
:
109 case ICAP_BITDEPTHREDUCTION
:
111 case ICAP_CUSTHALFTONE
:
113 case ICAP_PIXELFLAVOR
:
119 case ICAP_SUPPORTEDSIZES
:
122 case CAP_FEEDERALIGNMENT
:
123 case CAP_FEEDERENABLED
:
124 case CAP_FEEDERLOADED
:
125 case CAP_FEEDERORDER
:
127 case CAP_PAPERBINDING
:
128 case CAP_PAPERDETECTABLE
:
129 case CAP_REACQUIREALLOWED
:
131 case ICAP_PATCHCODEDETECTIONENABLED
:
132 case ICAP_SUPPORTEDPATCHCODETYPES
:
133 case ICAP_PATCHCODEMAXSEARCHPRIORITIES
:
134 case ICAP_PATCHCODESEARCHPRIORITIES
:
135 case ICAP_PATCHCODESEARCHMODE
:
136 case ICAP_PATCHCODEMAXRETRIES
:
137 case ICAP_PATCHCODETIMEOUT
:
138 case CAP_BATTERYMINUTES
:
139 case CAP_BATTERYPERCENTAGE
:
140 case CAP_POWERDOWNTIME
:
141 case CAP_POWERSUPPLY
:
142 case ICAP_XNATIVERESOLUTION
:
143 case ICAP_XRESOLUTION
:
144 case ICAP_YNATIVERESOLUTION
:
145 case ICAP_YRESOLUTION
:
146 twCC
= TWCC_CAPUNSUPPORTED
;
149 /* This is a required capability that every source need to
150 support but we havev't implemented yet. */
153 /*case ICAP_COMPRESSION:*/
154 case ICAP_IMAGEFILEFORMAT
:
156 twCC
= TWCC_CAPUNSUPPORTED
;
159 twCC
= TWAIN_ICAPXferMech (pSource
, pCapability
, action
);
161 case ICAP_UNDEFINEDIMAGESIZE
:
162 case CAP_CAMERAPREVIEWUI
:
163 case CAP_ENABLEDSUIONLY
:
165 case CAP_UICONTROLLABLE
:
166 twCC
= TWCC_CAPUNSUPPORTED
;
176 TW_BOOL
TWAIN_OneValueSet (pTW_CAPABILITY pCapability
, TW_UINT32 value
)
178 pCapability
->hContainer
= (TW_HANDLE
)GlobalAlloc (0, sizeof(TW_ONEVALUE
));
180 if (pCapability
->hContainer
)
182 pTW_ONEVALUE pVal
= GlobalLock ((HGLOBAL
) pCapability
->hContainer
);
183 pVal
->ItemType
= TWTY_UINT32
;
185 GlobalUnlock ((HGLOBAL
) pCapability
->hContainer
);
192 TW_BOOL
TWAIN_OneValueGet (pTW_CAPABILITY pCapability
, TW_UINT32
*pValue
)
194 pTW_ONEVALUE pVal
= GlobalLock ((HGLOBAL
) pCapability
->hContainer
);
198 *pValue
= pVal
->Item
;
199 GlobalUnlock ((HGLOBAL
) pCapability
->hContainer
);
207 TW_UINT16
TWAIN_ICAPXferMech (activeDS
*pSource
, pTW_CAPABILITY pCapability
,
210 TRACE("ICAP_XFERMECH\n");
215 if (pCapability
->ConType
== TWON_ONEVALUE
)
217 if (!TWAIN_OneValueSet (pCapability
, pSource
->capXferMech
))
218 return TWCC_LOWMEMORY
;
222 if (pCapability
->ConType
== TWON_ONEVALUE
)
224 TW_UINT32 xfermechtemp
;
225 if (!TWAIN_OneValueGet (pCapability
, &xfermechtemp
))
226 return TWCC_LOWMEMORY
;
227 pSource
->capXferMech
= xfermechtemp
;
229 else if (pCapability
->ConType
== TWON_ENUMERATION
)
235 if (!TWAIN_OneValueSet (pCapability
, pSource
->capXferMech
))
236 return TWCC_LOWMEMORY
;
239 if (!TWAIN_OneValueSet (pCapability
, TWSX_NATIVE
))
240 return TWCC_LOWMEMORY
;
243 pSource
->capXferMech
= TWSX_NATIVE
;