[SHELL32] CDrivesFolder: Implement the eject and disconnect menu items. CORE-13841
[reactos.git] / dll / win32 / windowscodecs / wincodecs_private.h
1 /*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #ifndef WINCODECS_PRIVATE_H
20 #define WINCODECS_PRIVATE_H
21
22 #include <wine/config.h>
23 #include <wine/port.h>
24
25 #include <stdarg.h>
26
27 #define WIN32_NO_STATUS
28 #define _INC_WINDOWS
29 #define COM_NO_WINDOWS_H
30
31 #define COBJMACROS
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
34
35 #include <windef.h>
36 #include <winbase.h>
37 #include <wingdi.h>
38 #include <winreg.h>
39 #include <objbase.h>
40 #include <oleauto.h>
41 #include <wincodec.h>
42 #include <wincodecsdk.h>
43
44 #include <wine/debug.h>
45 #include <wine/library.h>
46 #include <wine/unicode.h>
47
48 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
49
50 DEFINE_GUID(CLSID_WineTgaDecoder, 0xb11fc79a,0x67cc,0x43e6,0xa9,0xce,0xe3,0xd5,0x49,0x45,0xd3,0x04);
51
52 DEFINE_GUID(CLSID_WICIcnsEncoder, 0x312fb6f1,0xb767,0x409d,0x8a,0x6d,0x0f,0xc1,0x54,0xd4,0xf0,0x5c);
53
54 DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
55
56 DEFINE_GUID(GUID_VendorWine, 0xddf46da1,0x7dc1,0x404e,0x98,0xf2,0xef,0xa4,0x8d,0xfc,0x95,0x0a);
57
58 DEFINE_GUID(IID_IMILBitmap,0xb1784d3f,0x8115,0x4763,0x13,0xaa,0x32,0xed,0xdb,0x68,0x29,0x4a);
59 DEFINE_GUID(IID_IMILBitmapSource,0x7543696a,0xbc8d,0x46b0,0x5f,0x81,0x8d,0x95,0x72,0x89,0x72,0xbe);
60 DEFINE_GUID(IID_IMILBitmapLock,0xa67b2b53,0x8fa1,0x4155,0x8f,0x64,0x0c,0x24,0x7a,0x8f,0x84,0xcd);
61 DEFINE_GUID(IID_IMILBitmapScaler,0xa767b0f0,0x1c8c,0x4aef,0x56,0x8f,0xad,0xf9,0x6d,0xcf,0xd5,0xcb);
62 DEFINE_GUID(IID_IMILFormatConverter,0x7e2a746f,0x25c5,0x4851,0xb3,0xaf,0x44,0x3b,0x79,0x63,0x9e,0xc0);
63 DEFINE_GUID(IID_IMILPalette,0xca8e206f,0xf22c,0x4af7,0x6f,0xba,0x7b,0xed,0x5e,0xb1,0xc9,0x2f);
64
65 #define INTERFACE IMILBitmapSource
66 DECLARE_INTERFACE_(IMILBitmapSource,IUnknown)
67 {
68 /*** IUnknown methods ***/
69 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
70 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
71 STDMETHOD_(ULONG,Release)(THIS) PURE;
72 /*** IWICBitmapSource methods ***/
73 STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *) PURE;
74 STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *) PURE;
75 STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *) PURE;
76 STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *) PURE;
77 STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE;
78 /*** IMILBitmapSource methods ***/
79 STDMETHOD_(HRESULT,unknown1)(THIS_ void **) PURE;
80 STDMETHOD_(HRESULT,Lock)(THIS_ const WICRect *,DWORD,IWICBitmapLock **) PURE;
81 STDMETHOD_(HRESULT,Unlock)(THIS_ IWICBitmapLock *) PURE;
82 STDMETHOD_(HRESULT,SetPalette)(THIS_ IWICPalette *) PURE;
83 STDMETHOD_(HRESULT,SetResolution)(THIS_ double,double) PURE;
84 STDMETHOD_(HRESULT,AddDirtyRect)(THIS_ const WICRect *) PURE;
85 };
86 #undef INTERFACE
87
88 #define INTERFACE IMILBitmapScaler
89 DECLARE_INTERFACE_(IMILBitmapScaler,IUnknown)
90 {
91 /*** IUnknown methods ***/
92 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
93 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
94 STDMETHOD_(ULONG,Release)(THIS) PURE;
95 /*** IWICBitmapSource methods ***/
96 STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *) PURE;
97 STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *) PURE;
98 STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *) PURE;
99 STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *) PURE;
100 STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *) PURE;
101 /*** IMILBitmapScaler methods ***/
102 STDMETHOD_(HRESULT,unknown1)(THIS_ void **) PURE;
103 STDMETHOD_(HRESULT,Initialize)(THIS_ IMILBitmapSource *,UINT,UINT,WICBitmapInterpolationMode);
104 };
105 #undef INTERFACE
106
107 #ifdef __i386__ /* thiscall functions are i386-specific */
108
109 #define THISCALL(func) __thiscall_ ## func
110 #define DEFINE_THISCALL_WRAPPER(func,args) \
111 extern typeof(func) THISCALL(func); \
112 __ASM_STDCALL_FUNC(__thiscall_ ## func, args, \
113 "popl %eax\n\t" \
114 "pushl %ecx\n\t" \
115 "pushl %eax\n\t" \
116 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
117 #else /* __i386__ */
118
119 #define THISCALL(func) func
120 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
121
122 #endif /* __i386__ */
123
124 #define INTERFACE IMILUnknown1
125 DECLARE_INTERFACE_(IMILUnknown1,IUnknown)
126 {
127 /*** IUnknown methods ***/
128 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
129 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
130 STDMETHOD_(ULONG,Release)(THIS) PURE;
131 /*** thiscall method ***/
132 STDMETHOD_(void,unknown1)(THIS_ void*) PURE;
133 /*** stdcall ***/
134 STDMETHOD_(HRESULT,unknown2)(THIS_ void*, void*) PURE;
135 /*** thiscall method ***/
136 STDMETHOD_(HRESULT,unknown3)(THIS_ void*) PURE;
137 /*** stdcall ***/
138 STDMETHOD_(HRESULT,unknown4)(THIS_ void*) PURE;
139 STDMETHOD_(HRESULT,unknown5)(THIS_ void*) PURE;
140 STDMETHOD_(HRESULT,unknown6)(THIS_ DWORD64) PURE;
141 STDMETHOD_(HRESULT,unknown7)(THIS_ void*) PURE;
142 /*** thiscall method ***/
143 STDMETHOD_(HRESULT,unknown8)(THIS) PURE;
144 };
145 #undef INTERFACE
146
147 #define INTERFACE IMILUnknown2
148 DECLARE_INTERFACE_(IMILUnknown2,IUnknown)
149 {
150 /*** IUnknown methods ***/
151 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
152 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
153 STDMETHOD_(ULONG,Release)(THIS) PURE;
154 /*** unknown methods ***/
155 STDMETHOD_(HRESULT,unknown1)(THIS_ void *,void **) PURE;
156 STDMETHOD_(HRESULT,unknown2)(THIS_ void *,void *) PURE;
157 STDMETHOD_(HRESULT,unknown3)(THIS_ void *) PURE;
158 };
159 #undef INTERFACE
160
161 HRESULT create_instance(CLSID *clsid, const IID *iid, void **ppv) DECLSPEC_HIDDEN;
162
163 typedef HRESULT(*class_constructor)(REFIID,void**);
164 extern HRESULT FormatConverter_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
165 extern HRESULT ComponentFactory_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
166 extern HRESULT BmpDecoder_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
167 extern HRESULT PngDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
168 extern HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
169 extern HRESULT BmpEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
170 extern HRESULT DibDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
171 extern HRESULT GifDecoder_CreateInstance(REFIID riid, void** ppv) DECLSPEC_HIDDEN;
172 extern HRESULT GifEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
173 extern HRESULT IcoDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
174 extern HRESULT JpegDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
175 extern HRESULT JpegEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
176 extern HRESULT TiffDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
177 extern HRESULT TiffEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
178 extern HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
179 extern HRESULT TgaDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
180
181 extern HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
182 UINT stride, UINT datasize, BYTE *bits,
183 REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
184 IWICBitmap **ppIBitmap) DECLSPEC_HIDDEN;
185 extern HRESULT BitmapScaler_Create(IWICBitmapScaler **scaler) DECLSPEC_HIDDEN;
186 extern HRESULT FlipRotator_Create(IWICBitmapFlipRotator **fliprotator) DECLSPEC_HIDDEN;
187 extern HRESULT PaletteImpl_Create(IWICPalette **palette) DECLSPEC_HIDDEN;
188 extern HRESULT StreamImpl_Create(IWICStream **stream) DECLSPEC_HIDDEN;
189 extern HRESULT ColorContext_Create(IWICColorContext **context) DECLSPEC_HIDDEN;
190 extern HRESULT ColorTransform_Create(IWICColorTransform **transform) DECLSPEC_HIDDEN;
191 extern HRESULT BitmapClipper_Create(IWICBitmapClipper **clipper) DECLSPEC_HIDDEN;
192
193 extern HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
194 UINT srcwidth, UINT srcheight, INT srcstride,
195 const WICRect *rc, UINT dststride, UINT dstbuffersize, BYTE *dstbuffer) DECLSPEC_HIDDEN;
196
197 extern HRESULT configure_write_source(IWICBitmapFrameEncode *iface,
198 IWICBitmapSource *source, const WICRect *prc,
199 const WICPixelFormatGUID *format,
200 INT width, INT height, double xres, double yres) DECLSPEC_HIDDEN;
201
202 extern HRESULT write_source(IWICBitmapFrameEncode *iface,
203 IWICBitmapSource *source, const WICRect *prc,
204 const WICPixelFormatGUID *format, UINT bpp,
205 INT width, INT height) DECLSPEC_HIDDEN;
206
207 extern void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride) DECLSPEC_HIDDEN;
208
209 extern HRESULT get_pixelformat_bpp(const GUID *pixelformat, UINT *bpp) DECLSPEC_HIDDEN;
210
211 extern HRESULT CreatePropertyBag2(PROPBAG2 *options, UINT count,
212 IPropertyBag2 **property) DECLSPEC_HIDDEN;
213
214 extern HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo) DECLSPEC_HIDDEN;
215 extern HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown) DECLSPEC_HIDDEN;
216
217 typedef struct BmpDecoder BmpDecoder;
218
219 extern HRESULT IcoDibDecoder_CreateInstance(BmpDecoder **ppDecoder) DECLSPEC_HIDDEN;
220 extern void BmpDecoder_GetWICDecoder(BmpDecoder *This, IWICBitmapDecoder **ppDecoder) DECLSPEC_HIDDEN;
221 extern void BmpDecoder_FindIconMask(BmpDecoder *This, ULONG *mask_offset, int *topdown) DECLSPEC_HIDDEN;
222
223 typedef struct _MetadataItem
224 {
225 PROPVARIANT schema;
226 PROPVARIANT id;
227 PROPVARIANT value;
228 } MetadataItem;
229
230 typedef struct _MetadataHandlerVtbl
231 {
232 int is_writer;
233 const CLSID *clsid;
234 HRESULT (*fnLoad)(IStream *stream, const GUID *preferred_vendor,
235 DWORD persist_options, MetadataItem **items, DWORD *item_count);
236 HRESULT (*fnSave)(IStream *stream, DWORD persist_options,
237 const MetadataItem *items, DWORD item_count);
238 HRESULT (*fnGetSizeMax)(const MetadataItem *items, DWORD item_count,
239 ULARGE_INTEGER *size);
240 } MetadataHandlerVtbl;
241
242 extern HRESULT MetadataReader_Create(const MetadataHandlerVtbl *vtable, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
243
244 extern HRESULT UnknownMetadataReader_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
245 extern HRESULT IfdMetadataReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN;
246 extern HRESULT PngChrmReader_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
247 extern HRESULT PngGamaReader_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
248 extern HRESULT PngTextReader_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
249 extern HRESULT LSDReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN;
250 extern HRESULT IMDReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN;
251 extern HRESULT GCEReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN;
252 extern HRESULT APEReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN;
253 extern HRESULT GifCommentReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN;
254 extern HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *, const WCHAR *, IWICMetadataQueryReader **) DECLSPEC_HIDDEN;
255 extern HRESULT stream_initialize_from_filehandle(IWICStream *iface, HANDLE hfile) DECLSPEC_HIDDEN;
256
257 static inline WCHAR *heap_strdupW(const WCHAR *src)
258 {
259 WCHAR *dst;
260 SIZE_T len;
261 if (!src) return NULL;
262 len = (strlenW(src) + 1) * sizeof(WCHAR);
263 if ((dst = HeapAlloc(GetProcessHeap(), 0, len))) memcpy(dst, src, len);
264 return dst;
265 }
266
267 #endif /* WINCODECS_PRIVATE_H */