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 static TW_UINT16
SANE_ICAPXferMech (pTW_CAPABILITY pCapability
, TW_UINT16 action
);
36 TW_UINT16
SANE_SaneCapability (pTW_CAPABILITY pCapability
, TW_UINT16 action
)
38 TW_UINT16 twCC
= TWCC_SUCCESS
;
40 TRACE("capability=%d action=%d\n", pCapability
->Cap
, action
);
42 switch (pCapability
->Cap
)
47 case ACAP_AUDIOFILEFORMAT
:
49 case ICAP_AUTOMATICBORDERDETECTION
:
50 case ICAP_AUTOMATICDESKEW
:
51 case ICAP_AUTODISCARDBLANKPAGES
:
52 case ICAP_AUTOMATICROTATE
:
53 case ICAP_FLIPROTATION
:
54 case CAP_AUTOMATICCAPTURE
:
55 case CAP_TIMEBEFOREFIRSTCAPTURE
:
56 case CAP_TIMEBETWEENCAPTURES
:
58 case CAP_CLEARBUFFERS
:
59 case CAP_MAXBATCHBUFFERS
:
60 case ICAP_BARCODEDETECTIONENABLED
:
61 case ICAP_SUPPORTEDBARCODETYPES
:
62 case ICAP_BARCODEMAXSEARCHPRIORITIES
:
63 case ICAP_BARCODESEARCHPRIORITIES
:
64 case ICAP_BARCODESEARCHMODE
:
65 case ICAP_BARCODEMAXRETRIES
:
66 case ICAP_BARCODETIMEOUT
:
67 case CAP_EXTENDEDCAPS
:
68 case CAP_SUPPORTEDCAPS
:
71 case ICAP_PLANARCHUNKY
:
72 case ICAP_BITORDERCODES
:
73 case ICAP_CCITTKFACTOR
:
74 case ICAP_COMPRESSION
:
75 case ICAP_JPEGPIXELTYPE
:
76 /*case ICAP_JPEGQUALITY:*/
77 case ICAP_PIXELFLAVORCODES
:
79 case CAP_DEVICEONLINE
:
80 case CAP_DEVICETIMEDATE
:
81 case CAP_SERIALNUMBER
:
82 case ICAP_EXPOSURETIME
:
84 case ICAP_IMAGEFILTER
:
87 case ICAP_NOISEFILTER
:
89 case ICAP_PHYSICALHEIGHT
:
90 case ICAP_PHYSICALWIDTH
:
94 case CAP_PRINTERENABLED
:
95 case CAP_PRINTERINDEX
:
97 case CAP_PRINTERSTRING
:
98 case CAP_PRINTERSUFFIX
:
102 case ICAP_AUTOBRIGHT
:
103 case ICAP_BRIGHTNESS
:
106 case ICAP_ORIENTATION
:
112 case ICAP_BITDEPTHREDUCTION
:
114 case ICAP_CUSTHALFTONE
:
116 case ICAP_PIXELFLAVOR
:
122 case ICAP_SUPPORTEDSIZES
:
125 case CAP_FEEDERALIGNMENT
:
126 case CAP_FEEDERENABLED
:
127 case CAP_FEEDERLOADED
:
128 case CAP_FEEDERORDER
:
130 case CAP_PAPERBINDING
:
131 case CAP_PAPERDETECTABLE
:
132 case CAP_REACQUIREALLOWED
:
134 case ICAP_PATCHCODEDETECTIONENABLED
:
135 case ICAP_SUPPORTEDPATCHCODETYPES
:
136 case ICAP_PATCHCODEMAXSEARCHPRIORITIES
:
137 case ICAP_PATCHCODESEARCHPRIORITIES
:
138 case ICAP_PATCHCODESEARCHMODE
:
139 case ICAP_PATCHCODEMAXRETRIES
:
140 case ICAP_PATCHCODETIMEOUT
:
141 case CAP_BATTERYMINUTES
:
142 case CAP_BATTERYPERCENTAGE
:
143 case CAP_POWERDOWNTIME
:
144 case CAP_POWERSUPPLY
:
145 case ICAP_XNATIVERESOLUTION
:
146 case ICAP_XRESOLUTION
:
147 case ICAP_YNATIVERESOLUTION
:
148 case ICAP_YRESOLUTION
:
149 twCC
= TWCC_CAPUNSUPPORTED
;
152 /* This is a required capability that every source needs to
153 support but we haven't implemented it yet. */
156 /*case ICAP_COMPRESSION:*/
157 case ICAP_IMAGEFILEFORMAT
:
159 twCC
= TWCC_CAPUNSUPPORTED
;
162 twCC
= SANE_ICAPXferMech (pCapability
, action
);
164 case ICAP_UNDEFINEDIMAGESIZE
:
165 case CAP_CAMERAPREVIEWUI
:
166 case CAP_ENABLEDSUIONLY
:
168 case CAP_UICONTROLLABLE
:
169 twCC
= TWCC_CAPUNSUPPORTED
;
179 static TW_BOOL
TWAIN_OneValueSet (pTW_CAPABILITY pCapability
, TW_UINT32 value
)
181 pCapability
->hContainer
= GlobalAlloc (0, sizeof(TW_ONEVALUE
));
183 if (pCapability
->hContainer
)
185 pTW_ONEVALUE pVal
= GlobalLock (pCapability
->hContainer
);
186 pVal
->ItemType
= TWTY_UINT32
;
188 GlobalUnlock (pCapability
->hContainer
);
195 static TW_BOOL
TWAIN_OneValueGet (pTW_CAPABILITY pCapability
, TW_UINT32
*pValue
)
197 pTW_ONEVALUE pVal
= GlobalLock (pCapability
->hContainer
);
201 *pValue
= pVal
->Item
;
202 GlobalUnlock (pCapability
->hContainer
);
210 static TW_UINT16
SANE_ICAPXferMech (pTW_CAPABILITY pCapability
, TW_UINT16 action
)
212 TRACE("ICAP_XFERMECH\n");
217 if (pCapability
->ConType
== TWON_ONEVALUE
)
219 if (!TWAIN_OneValueSet (pCapability
, activeDS
.capXferMech
))
220 return TWCC_LOWMEMORY
;
224 if (pCapability
->ConType
== TWON_ONEVALUE
)
226 TW_UINT32 xfermechtemp
= 0;
227 if (!TWAIN_OneValueGet (pCapability
, &xfermechtemp
))
228 return TWCC_LOWMEMORY
;
229 activeDS
.capXferMech
= xfermechtemp
;
231 else if (pCapability
->ConType
== TWON_ENUMERATION
)
237 if (!TWAIN_OneValueSet (pCapability
, activeDS
.capXferMech
))
238 return TWCC_LOWMEMORY
;
241 if (!TWAIN_OneValueSet (pCapability
, TWSX_NATIVE
))
242 return TWCC_LOWMEMORY
;
245 activeDS
.capXferMech
= TWSX_NATIVE
;