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
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(twain
);
34 TW_UINT16
TWAIN_SaneCapability (activeDS
*pSource
, pTW_CAPABILITY pCapability
,
37 TW_UINT16 twCC
= TWCC_SUCCESS
;
39 TRACE("capability=%d action=%d\n", pCapability
->Cap
, action
);
41 switch (pCapability
->Cap
)
46 case ACAP_AUDIOFILEFORMAT
:
48 case ICAP_AUTOMATICBORDERDETECTION
:
49 case ICAP_AUTOMATICDESKEW
:
50 case ICAP_AUTODISCARDBLANKPAGES
:
51 case ICAP_AUTOMATICROTATE
:
52 case ICAP_FLIPROTATION
:
53 case CAP_AUTOMATICCAPTURE
:
54 case CAP_TIMEBEFOREFIRSTCAPTURE
:
55 case CAP_TIMEBETWEENCAPTURES
:
57 case CAP_CLEARBUFFERS
:
58 case CAP_MAXBATCHBUFFERS
:
59 case ICAP_BARCODEDETECTIONENABLED
:
60 case ICAP_SUPPORTEDBARCODETYPES
:
61 case ICAP_BARCODEMAXSEARCHPRIORITIES
:
62 case ICAP_BARCODESEARCHPRIORITIES
:
63 case ICAP_BARCODESEARCHMODE
:
64 case ICAP_BARCODEMAXRETRIES
:
65 case ICAP_BARCODETIMEOUT
:
66 case CAP_EXTENDEDCAPS
:
67 case CAP_SUPPORTEDCAPS
:
70 case ICAP_PLANARCHUNKY
:
71 case ICAP_BITORDERCODES
:
72 case ICAP_CCITTKFACTOR
:
73 case ICAP_COMPRESSION
:
74 case ICAP_JPEGPIXELTYPE
:
75 /*case ICAP_JPEGQUALITY:*/
76 case ICAP_PIXELFLAVORCODES
:
78 case CAP_DEVICEONLINE
:
79 case CAP_DEVICETIMEDATE
:
80 case CAP_SERIALNUMBER
:
81 case ICAP_EXPOSURETIME
:
83 case ICAP_IMAGEFILTER
:
86 case ICAP_NOISEFILTER
:
88 case ICAP_PHYSICALHEIGHT
:
89 case ICAP_PHYSICALWIDTH
:
93 case CAP_PRINTERENABLED
:
94 case CAP_PRINTERINDEX
:
96 case CAP_PRINTERSTRING
:
97 case CAP_PRINTERSUFFIX
:
101 case ICAP_AUTOBRIGHT
:
102 case ICAP_BRIGHTNESS
:
105 case ICAP_ORIENTATION
:
111 case ICAP_BITDEPTHREDUCTION
:
113 case ICAP_CUSTHALFTONE
:
115 case ICAP_PIXELFLAVOR
:
121 case ICAP_SUPPORTEDSIZES
:
124 case CAP_FEEDERALIGNMENT
:
125 case CAP_FEEDERENABLED
:
126 case CAP_FEEDERLOADED
:
127 case CAP_FEEDERORDER
:
129 case CAP_PAPERBINDING
:
130 case CAP_PAPERDETECTABLE
:
131 case CAP_REACQUIREALLOWED
:
133 case ICAP_PATCHCODEDETECTIONENABLED
:
134 case ICAP_SUPPORTEDPATCHCODETYPES
:
135 case ICAP_PATCHCODEMAXSEARCHPRIORITIES
:
136 case ICAP_PATCHCODESEARCHPRIORITIES
:
137 case ICAP_PATCHCODESEARCHMODE
:
138 case ICAP_PATCHCODEMAXRETRIES
:
139 case ICAP_PATCHCODETIMEOUT
:
140 case CAP_BATTERYMINUTES
:
141 case CAP_BATTERYPERCENTAGE
:
142 case CAP_POWERDOWNTIME
:
143 case CAP_POWERSUPPLY
:
144 case ICAP_XNATIVERESOLUTION
:
145 case ICAP_XRESOLUTION
:
146 case ICAP_YNATIVERESOLUTION
:
147 case ICAP_YRESOLUTION
:
148 twCC
= TWCC_CAPUNSUPPORTED
;
151 /* This is a required capability that every source need to
152 support but we havev't implemented yet. */
155 /*case ICAP_COMPRESSION:*/
156 case ICAP_IMAGEFILEFORMAT
:
158 twCC
= TWCC_CAPUNSUPPORTED
;
161 twCC
= TWAIN_ICAPXferMech (pSource
, pCapability
, action
);
163 case ICAP_UNDEFINEDIMAGESIZE
:
164 case CAP_CAMERAPREVIEWUI
:
165 case CAP_ENABLEDSUIONLY
:
167 case CAP_UICONTROLLABLE
:
168 twCC
= TWCC_CAPUNSUPPORTED
;
178 static TW_BOOL
TWAIN_OneValueSet (pTW_CAPABILITY pCapability
, TW_UINT32 value
)
180 pCapability
->hContainer
= (TW_HANDLE
)GlobalAlloc (0, sizeof(TW_ONEVALUE
));
182 if (pCapability
->hContainer
)
184 pTW_ONEVALUE pVal
= GlobalLock ((HGLOBAL
) pCapability
->hContainer
);
185 pVal
->ItemType
= TWTY_UINT32
;
187 GlobalUnlock ((HGLOBAL
) pCapability
->hContainer
);
194 static TW_BOOL
TWAIN_OneValueGet (pTW_CAPABILITY pCapability
, TW_UINT32
*pValue
)
196 pTW_ONEVALUE pVal
= GlobalLock ((HGLOBAL
) pCapability
->hContainer
);
200 *pValue
= pVal
->Item
;
201 GlobalUnlock ((HGLOBAL
) pCapability
->hContainer
);
209 TW_UINT16
TWAIN_ICAPXferMech (activeDS
*pSource
, pTW_CAPABILITY pCapability
,
212 TRACE("ICAP_XFERMECH\n");
217 if (pCapability
->ConType
== TWON_ONEVALUE
)
219 if (!TWAIN_OneValueSet (pCapability
, pSource
->capXferMech
))
220 return TWCC_LOWMEMORY
;
224 if (pCapability
->ConType
== TWON_ONEVALUE
)
226 TW_UINT32 xfermechtemp
;
227 if (!TWAIN_OneValueGet (pCapability
, &xfermechtemp
))
228 return TWCC_LOWMEMORY
;
229 pSource
->capXferMech
= xfermechtemp
;
231 else if (pCapability
->ConType
== TWON_ENUMERATION
)
237 if (!TWAIN_OneValueSet (pCapability
, pSource
->capXferMech
))
238 return TWCC_LOWMEMORY
;
241 if (!TWAIN_OneValueSet (pCapability
, TWSX_NATIVE
))
242 return TWCC_LOWMEMORY
;
245 pSource
->capXferMech
= TWSX_NATIVE
;