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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define NONAMELESSUNION
20 #define NONAMELESSSTRUCT
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(twain
);
34 TW_UINT16
SANE_SaneCapability (pTW_CAPABILITY pCapability
, TW_UINT16 action
)
36 TW_UINT16 twCC
= TWCC_SUCCESS
;
38 TRACE("capability=%d action=%d\n", pCapability
->Cap
, action
);
40 switch (pCapability
->Cap
)
45 case ACAP_AUDIOFILEFORMAT
:
47 case ICAP_AUTOMATICBORDERDETECTION
:
48 case ICAP_AUTOMATICDESKEW
:
49 case ICAP_AUTODISCARDBLANKPAGES
:
50 case ICAP_AUTOMATICROTATE
:
51 case ICAP_FLIPROTATION
:
52 case CAP_AUTOMATICCAPTURE
:
53 case CAP_TIMEBEFOREFIRSTCAPTURE
:
54 case CAP_TIMEBETWEENCAPTURES
:
56 case CAP_CLEARBUFFERS
:
57 case CAP_MAXBATCHBUFFERS
:
58 case ICAP_BARCODEDETECTIONENABLED
:
59 case ICAP_SUPPORTEDBARCODETYPES
:
60 case ICAP_BARCODEMAXSEARCHPRIORITIES
:
61 case ICAP_BARCODESEARCHPRIORITIES
:
62 case ICAP_BARCODESEARCHMODE
:
63 case ICAP_BARCODEMAXRETRIES
:
64 case ICAP_BARCODETIMEOUT
:
65 case CAP_EXTENDEDCAPS
:
66 case CAP_SUPPORTEDCAPS
:
69 case ICAP_PLANARCHUNKY
:
70 case ICAP_BITORDERCODES
:
71 case ICAP_CCITTKFACTOR
:
72 case ICAP_COMPRESSION
:
73 case ICAP_JPEGPIXELTYPE
:
74 /*case ICAP_JPEGQUALITY:*/
75 case ICAP_PIXELFLAVORCODES
:
77 case CAP_DEVICEONLINE
:
78 case CAP_DEVICETIMEDATE
:
79 case CAP_SERIALNUMBER
:
80 case ICAP_EXPOSURETIME
:
82 case ICAP_IMAGEFILTER
:
85 case ICAP_NOISEFILTER
:
87 case ICAP_PHYSICALHEIGHT
:
88 case ICAP_PHYSICALWIDTH
:
92 case CAP_PRINTERENABLED
:
93 case CAP_PRINTERINDEX
:
95 case CAP_PRINTERSTRING
:
96 case CAP_PRINTERSUFFIX
:
100 case ICAP_AUTOBRIGHT
:
101 case ICAP_BRIGHTNESS
:
104 case ICAP_ORIENTATION
:
110 case ICAP_BITDEPTHREDUCTION
:
112 case ICAP_CUSTHALFTONE
:
114 case ICAP_PIXELFLAVOR
:
120 case ICAP_SUPPORTEDSIZES
:
123 case CAP_FEEDERALIGNMENT
:
124 case CAP_FEEDERENABLED
:
125 case CAP_FEEDERLOADED
:
126 case CAP_FEEDERORDER
:
128 case CAP_PAPERBINDING
:
129 case CAP_PAPERDETECTABLE
:
130 case CAP_REACQUIREALLOWED
:
132 case ICAP_PATCHCODEDETECTIONENABLED
:
133 case ICAP_SUPPORTEDPATCHCODETYPES
:
134 case ICAP_PATCHCODEMAXSEARCHPRIORITIES
:
135 case ICAP_PATCHCODESEARCHPRIORITIES
:
136 case ICAP_PATCHCODESEARCHMODE
:
137 case ICAP_PATCHCODEMAXRETRIES
:
138 case ICAP_PATCHCODETIMEOUT
:
139 case CAP_BATTERYMINUTES
:
140 case CAP_BATTERYPERCENTAGE
:
141 case CAP_POWERDOWNTIME
:
142 case CAP_POWERSUPPLY
:
143 case ICAP_XNATIVERESOLUTION
:
144 case ICAP_XRESOLUTION
:
145 case ICAP_YNATIVERESOLUTION
:
146 case ICAP_YRESOLUTION
:
147 twCC
= TWCC_CAPUNSUPPORTED
;
150 /* This is a required capability that every source need to
151 support but we havev't implemented yet. */
154 /*case ICAP_COMPRESSION:*/
155 case ICAP_IMAGEFILEFORMAT
:
157 twCC
= TWCC_CAPUNSUPPORTED
;
160 twCC
= SANE_ICAPXferMech (pCapability
, action
);
162 case ICAP_UNDEFINEDIMAGESIZE
:
163 case CAP_CAMERAPREVIEWUI
:
164 case CAP_ENABLEDSUIONLY
:
166 case CAP_UICONTROLLABLE
:
167 twCC
= TWCC_CAPUNSUPPORTED
;
177 static TW_BOOL
TWAIN_OneValueSet (pTW_CAPABILITY pCapability
, TW_UINT32 value
)
179 pCapability
->hContainer
= GlobalAlloc (0, sizeof(TW_ONEVALUE
));
181 if (pCapability
->hContainer
)
183 pTW_ONEVALUE pVal
= GlobalLock (pCapability
->hContainer
);
184 pVal
->ItemType
= TWTY_UINT32
;
186 GlobalUnlock (pCapability
->hContainer
);
193 static TW_BOOL
TWAIN_OneValueGet (pTW_CAPABILITY pCapability
, TW_UINT32
*pValue
)
195 pTW_ONEVALUE pVal
= GlobalLock (pCapability
->hContainer
);
199 *pValue
= pVal
->Item
;
200 GlobalUnlock (pCapability
->hContainer
);
208 TW_UINT16
SANE_ICAPXferMech (pTW_CAPABILITY pCapability
, TW_UINT16 action
)
210 TRACE("ICAP_XFERMECH\n");
215 if (pCapability
->ConType
== TWON_ONEVALUE
)
217 if (!TWAIN_OneValueSet (pCapability
, activeDS
.capXferMech
))
218 return TWCC_LOWMEMORY
;
222 if (pCapability
->ConType
== TWON_ONEVALUE
)
224 TW_UINT32 xfermechtemp
= 0;
225 if (!TWAIN_OneValueGet (pCapability
, &xfermechtemp
))
226 return TWCC_LOWMEMORY
;
227 activeDS
.capXferMech
= xfermechtemp
;
229 else if (pCapability
->ConType
== TWON_ENUMERATION
)
235 if (!TWAIN_OneValueSet (pCapability
, activeDS
.capXferMech
))
236 return TWCC_LOWMEMORY
;
239 if (!TWAIN_OneValueSet (pCapability
, TWSX_NATIVE
))
240 return TWCC_LOWMEMORY
;
243 activeDS
.capXferMech
= TWSX_NATIVE
;