1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
* Copyright 2000 Corel Corporation
* Copyright 2006 Marcus Meissner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _TWAIN32_H
#define _TWAIN32_H
#ifndef __WINE_CONFIG_H
# error You must include config.h first
#endif
#if !defined(HAVE_JPEGLIB_H)
# warning "gphoto2 support in twain needs jpeg development headers"
# undef HAVE_GPHOTO2
#endif
#ifdef HAVE_GPHOTO2
/* Hack for gphoto2, which changes behaviour when WIN32 is set. */
#undef WIN32
#include <gphoto2/gphoto2-camera.h>
#define WIN32
#endif
#include <stdio.h>
#ifdef HAVE_JPEGLIB_H
/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
# define XMD_H
# define UINT8 JPEG_UINT8
# define UINT16 JPEG_UINT16
# undef FAR
# include <jpeglib.h>
# undef UINT16
# ifndef SONAME_LIBJPEG
# define SONAME_LIBJPEG "libjpeg.so"
# endif
#endif
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "twain.h"
#include "wine/list.h"
extern HINSTANCE GPHOTO2_instance;
struct gphoto2_file {
struct list entry;
char *folder;
char *filename;
BOOL download; /* flag for downloading, set by GUI or so */
};
/* internal information about an active data source */
struct tagActiveDS
{
TW_IDENTITY identity; /* identity */
TW_UINT16 currentState; /* current state */
TW_EVENT pendingEvent; /* pending event to be sent to
application */
TW_UINT16 twCC; /* condition code */
HWND hwndOwner; /* window handle of the app */
HWND progressWnd; /* window handle of the scanning window */
#ifdef HAVE_GPHOTO2
Camera *camera;
GPContext *context;
#endif
/* Capabiblities */
TW_UINT32 capXferMech; /* ICAP_XFERMECH */
TW_UINT16 pixeltype; /* ICAP_PIXELTYPE */
TW_UINT16 pixelflavor; /* ICAP_PIXELFLAVOR */
struct list files;
/* Download and decode JPEG STATE */
#ifdef HAVE_GPHOTO2
CameraFile *file;
#endif
#ifdef HAVE_JPEGLIB_H
struct jpeg_source_mgr xjsm;
struct jpeg_decompress_struct jd;
struct jpeg_error_mgr jerr;
#endif
} activeDS;
/* Helper functions */
extern TW_UINT16 GPHOTO2_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action);
/* */
extern TW_UINT16 GPHOTO2_ControlGroupHandler (
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
extern TW_UINT16 GPHOTO2_ImageGroupHandler (
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
extern TW_UINT16 GPHOTO2_AudioGroupHandler (
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
extern TW_UINT16 GPHOTO2_SourceManagerHandler (
pTW_IDENTITY pOrigin, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
/* Implementation of operation triplets
* From Application to Source (Control Information) */
TW_UINT16 GPHOTO2_CapabilityGet (pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CapabilityGetCurrent
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CapabilityGetDefault
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CapabilityQuerySupport
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CapabilityReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CapabilitySet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CustomDSDataGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CustomDSDataSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_AutomaticCaptureDirectory
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ChangeDirectory
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemCopy
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_CreateDirectory
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemDelete
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FormatMedia
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemGetClose
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemGetFirstFile
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemGetInfo
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemGetNextFile
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_FileSystemRename
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ProcessEvent
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_PassThrough
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_PendingXfersEndXfer
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_PendingXfersGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_PendingXfersReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_PendingXfersStopFeeder
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXferGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXferGetDefault
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXferReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXferSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXfer2Get
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXfer2GetDefault
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXfer2Reset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupFileXfer2Set
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_SetupMemXferGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_GetDSStatus
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_DisableDSUserInterface
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_EnableDSUserInterface
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_EnableDSUIOnly
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_XferGroupGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_XferGroupSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
/* Implementation of operation triplets
* From Application to Source (Image Information) */
TW_UINT16 GPHOTO2_CIEColorGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ExtImageInfoGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_GrayResponseReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_GrayResponseSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageFileXferGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageInfoGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageLayoutGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageLayoutGetDefault
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageLayoutReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageLayoutSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageMemXferGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_ImageNativeXferGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_JPEGCompressionGet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_JPEGCompressionGetDefault
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_JPEGCompressionReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_JPEGCompressionSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_Palette8Get
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_Palette8GetDefault
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_Palette8Reset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_Palette8Set
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_RGBResponseReset
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
TW_UINT16 GPHOTO2_RGBResponseSet
(pTW_IDENTITY pOrigin, TW_MEMREF pData);
/* UI function */
BOOL DoCameraUI(void);
HWND TransferringDialogBox(HWND dialog, DWORD progress);
#ifdef HAVE_GPHOTO2
/* Helper function for GUI */
TW_UINT16
_get_gphoto2_file_as_DIB(
const char *folder, const char *filename, CameraFileType type,
HWND hwnd, HBITMAP *hDIB
);
#endif
#endif