2 * Copyright 2009 Vincent Povirk for CodeWeavers
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 #ifndef WINCODECS_PRIVATE_H
20 #define WINCODECS_PRIVATE_H
23 #include "wincodecsdk.h"
25 #include "wine/debug.h"
26 #include "wine/unicode.h"
28 DEFINE_GUID(CLSID_WineTgaDecoder
, 0xb11fc79a,0x67cc,0x43e6,0xa9,0xce,0xe3,0xd5,0x49,0x45,0xd3,0x04);
30 DEFINE_GUID(CLSID_WICIcnsEncoder
, 0x312fb6f1,0xb767,0x409d,0x8a,0x6d,0x0f,0xc1,0x54,0xd4,0xf0,0x5c);
32 DEFINE_GUID(GUID_WineContainerFormatTga
, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
34 DEFINE_GUID(GUID_VendorWine
, 0xddf46da1,0x7dc1,0x404e,0x98,0xf2,0xef,0xa4,0x8d,0xfc,0x95,0x0a);
36 extern IID IID_IMILBitmap
;
37 extern IID IID_IMILBitmapSource
;
38 extern IID IID_IMILBitmapLock
;
39 extern IID IID_IMILBitmapScaler
;
40 extern IID IID_IMILFormatConverter
;
41 extern IID IID_IMILPalette
;
43 #define INTERFACE IMILBitmapSource
44 DECLARE_INTERFACE_(IMILBitmapSource
,IUnknown
)
46 /*** IUnknown methods ***/
47 STDMETHOD_(HRESULT
,QueryInterface
)(THIS_ REFIID
,void **) PURE
;
48 STDMETHOD_(ULONG
,AddRef
)(THIS
) PURE
;
49 STDMETHOD_(ULONG
,Release
)(THIS
) PURE
;
50 /*** IWICBitmapSource methods ***/
51 STDMETHOD_(HRESULT
,GetSize
)(THIS_ UINT
*,UINT
*) PURE
;
52 STDMETHOD_(HRESULT
,GetPixelFormat
)(THIS_
int *) PURE
;
53 STDMETHOD_(HRESULT
,GetResolution
)(THIS_
double *,double *) PURE
;
54 STDMETHOD_(HRESULT
,CopyPalette
)(THIS_ IWICPalette
*) PURE
;
55 STDMETHOD_(HRESULT
,CopyPixels
)(THIS_
const WICRect
*,UINT
,UINT
,BYTE
*) PURE
;
59 #define INTERFACE IMILBitmap
60 DECLARE_INTERFACE_(IMILBitmap
,IMILBitmapSource
)
62 /*** IUnknown methods ***/
63 STDMETHOD_(HRESULT
,QueryInterface
)(THIS_ REFIID
,void **) PURE
;
64 STDMETHOD_(ULONG
,AddRef
)(THIS
) PURE
;
65 STDMETHOD_(ULONG
,Release
)(THIS
) PURE
;
66 /*** IWICBitmapSource methods ***/
67 STDMETHOD_(HRESULT
,GetSize
)(THIS_ UINT
*,UINT
*) PURE
;
68 STDMETHOD_(HRESULT
,GetPixelFormat
)(THIS_
int *) PURE
;
69 STDMETHOD_(HRESULT
,GetResolution
)(THIS_
double *,double *) PURE
;
70 STDMETHOD_(HRESULT
,CopyPalette
)(THIS_ IWICPalette
*) PURE
;
71 STDMETHOD_(HRESULT
,CopyPixels
)(THIS_
const WICRect
*,UINT
,UINT
,BYTE
*) PURE
;
72 /*** IMILBitmap methods ***/
73 STDMETHOD_(HRESULT
,unknown1
)(THIS_
void **) PURE
;
74 STDMETHOD_(HRESULT
,Lock
)(THIS_
const WICRect
*,DWORD
,IWICBitmapLock
**) PURE
;
75 STDMETHOD_(HRESULT
,Unlock
)(THIS_ IWICBitmapLock
*) PURE
;
76 STDMETHOD_(HRESULT
,SetPalette
)(THIS_ IWICPalette
*) PURE
;
77 STDMETHOD_(HRESULT
,SetResolution
)(THIS_
double,double) PURE
;
78 STDMETHOD_(HRESULT
,AddDirtyRect
)(THIS_
const WICRect
*) PURE
;
82 #define INTERFACE IMILBitmapScaler
83 DECLARE_INTERFACE_(IMILBitmapScaler
,IMILBitmapSource
)
85 /*** IUnknown methods ***/
86 STDMETHOD_(HRESULT
,QueryInterface
)(THIS_ REFIID
,void **) PURE
;
87 STDMETHOD_(ULONG
,AddRef
)(THIS
) PURE
;
88 STDMETHOD_(ULONG
,Release
)(THIS
) PURE
;
89 /*** IWICBitmapSource methods ***/
90 STDMETHOD_(HRESULT
,GetSize
)(THIS_ UINT
*,UINT
*) PURE
;
91 STDMETHOD_(HRESULT
,GetPixelFormat
)(THIS_
int *) PURE
;
92 STDMETHOD_(HRESULT
,GetResolution
)(THIS_
double *,double *) PURE
;
93 STDMETHOD_(HRESULT
,CopyPalette
)(THIS_ IWICPalette
*) PURE
;
94 STDMETHOD_(HRESULT
,CopyPixels
)(THIS_
const WICRect
*,UINT
,UINT
,BYTE
*) PURE
;
95 /*** IMILBitmapScaler methods ***/
96 STDMETHOD_(HRESULT
,unknown1
)(THIS_
void **) PURE
;
97 STDMETHOD_(HRESULT
,Initialize
)(THIS_ IMILBitmapSource
*,UINT
,UINT
,WICBitmapInterpolationMode
) PURE
;
101 #define THISCALLMETHOD_(type,method) type (__thiscall *method)
103 #define INTERFACE IMILUnknown1
104 DECLARE_INTERFACE_(IMILUnknown1
,IUnknown
)
106 /*** IUnknown methods ***/
107 STDMETHOD_(HRESULT
,QueryInterface
)(THIS_ REFIID
,void **) PURE
;
108 STDMETHOD_(ULONG
,AddRef
)(THIS
) PURE
;
109 STDMETHOD_(ULONG
,Release
)(THIS
) PURE
;
110 THISCALLMETHOD_(void,unknown1
)(THIS_
void*) PURE
;
111 STDMETHOD_(HRESULT
,unknown2
)(THIS_
void*, void*) PURE
;
112 THISCALLMETHOD_(HRESULT
,unknown3
)(THIS_
void*) PURE
;
113 STDMETHOD_(HRESULT
,unknown4
)(THIS_
void*) PURE
;
114 STDMETHOD_(HRESULT
,unknown5
)(THIS_
void*) PURE
;
115 STDMETHOD_(HRESULT
,unknown6
)(THIS_ DWORD64
) PURE
;
116 STDMETHOD_(HRESULT
,unknown7
)(THIS_
void*) PURE
;
117 THISCALLMETHOD_(HRESULT
,unknown8
)(THIS
) PURE
;
121 #define INTERFACE IMILUnknown2
122 DECLARE_INTERFACE_(IMILUnknown2
,IUnknown
)
124 /*** IUnknown methods ***/
125 STDMETHOD_(HRESULT
,QueryInterface
)(THIS_ REFIID
,void **) PURE
;
126 STDMETHOD_(ULONG
,AddRef
)(THIS
) PURE
;
127 STDMETHOD_(ULONG
,Release
)(THIS
) PURE
;
128 /*** unknown methods ***/
129 STDMETHOD_(HRESULT
,unknown1
)(THIS_
void *,void **) PURE
;
130 STDMETHOD_(HRESULT
,unknown2
)(THIS_
void *,void *) PURE
;
131 STDMETHOD_(HRESULT
,unknown3
)(THIS_
void *) PURE
;
135 HRESULT
create_instance(CLSID
*clsid
, const IID
*iid
, void **ppv
) DECLSPEC_HIDDEN
;
137 typedef HRESULT(*class_constructor
)(REFIID
,void**);
138 extern HRESULT
FormatConverter_CreateInstance(REFIID riid
, void** ppv
) DECLSPEC_HIDDEN
;
139 extern HRESULT
ImagingFactory_CreateInstance(REFIID riid
, void** ppv
) DECLSPEC_HIDDEN
;
140 extern HRESULT
BmpDecoder_CreateInstance(REFIID riid
, void** ppv
) DECLSPEC_HIDDEN
;
141 extern HRESULT
PngDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
142 extern HRESULT
PngEncoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
143 extern HRESULT
BmpEncoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
144 extern HRESULT
DibDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
145 extern HRESULT
GifDecoder_CreateInstance(REFIID riid
, void** ppv
) DECLSPEC_HIDDEN
;
146 extern HRESULT
GifEncoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
147 extern HRESULT
IcoDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
148 extern HRESULT
JpegDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
149 extern HRESULT
JpegEncoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
150 extern HRESULT
TiffDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
151 extern HRESULT
TiffEncoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
152 extern HRESULT
IcnsEncoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
153 extern HRESULT
TgaDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
154 extern HRESULT
DdsDecoder_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
156 extern HRESULT
BitmapImpl_Create(UINT uiWidth
, UINT uiHeight
,
157 UINT stride
, UINT datasize
, void *view
, UINT offset
,
158 REFWICPixelFormatGUID pixelFormat
, WICBitmapCreateCacheOption option
,
159 IWICBitmap
**ppIBitmap
) DECLSPEC_HIDDEN
;
160 extern HRESULT
BitmapScaler_Create(IWICBitmapScaler
**scaler
) DECLSPEC_HIDDEN
;
161 extern HRESULT
FlipRotator_Create(IWICBitmapFlipRotator
**fliprotator
) DECLSPEC_HIDDEN
;
162 extern HRESULT
PaletteImpl_Create(IWICPalette
**palette
) DECLSPEC_HIDDEN
;
163 extern HRESULT
StreamImpl_Create(IWICStream
**stream
) DECLSPEC_HIDDEN
;
164 extern HRESULT
ColorContext_Create(IWICColorContext
**context
) DECLSPEC_HIDDEN
;
165 extern HRESULT
ColorTransform_Create(IWICColorTransform
**transform
) DECLSPEC_HIDDEN
;
166 extern HRESULT
BitmapClipper_Create(IWICBitmapClipper
**clipper
) DECLSPEC_HIDDEN
;
168 extern HRESULT
copy_pixels(UINT bpp
, const BYTE
*srcbuffer
,
169 UINT srcwidth
, UINT srcheight
, INT srcstride
,
170 const WICRect
*rc
, UINT dststride
, UINT dstbuffersize
, BYTE
*dstbuffer
) DECLSPEC_HIDDEN
;
172 extern HRESULT
configure_write_source(IWICBitmapFrameEncode
*iface
,
173 IWICBitmapSource
*source
, const WICRect
*prc
,
174 const WICPixelFormatGUID
*format
,
175 INT width
, INT height
, double xres
, double yres
) DECLSPEC_HIDDEN
;
177 extern HRESULT
write_source(IWICBitmapFrameEncode
*iface
,
178 IWICBitmapSource
*source
, const WICRect
*prc
,
179 const WICPixelFormatGUID
*format
, UINT bpp
, BOOL need_palette
,
180 INT width
, INT height
) DECLSPEC_HIDDEN
;
182 extern void reverse_bgr8(UINT bytesperpixel
, LPBYTE bits
, UINT width
, UINT height
, INT stride
) DECLSPEC_HIDDEN
;
184 extern HRESULT
get_pixelformat_bpp(const GUID
*pixelformat
, UINT
*bpp
) DECLSPEC_HIDDEN
;
186 extern HRESULT
CreatePropertyBag2(const PROPBAG2
*options
, UINT count
,
187 IPropertyBag2
**property
) DECLSPEC_HIDDEN
;
189 extern HRESULT
CreateComponentInfo(REFCLSID clsid
, IWICComponentInfo
**ppIInfo
) DECLSPEC_HIDDEN
;
190 extern void ReleaseComponentInfos(void) DECLSPEC_HIDDEN
;
191 extern HRESULT
CreateComponentEnumerator(DWORD componentTypes
, DWORD options
, IEnumUnknown
**ppIEnumUnknown
) DECLSPEC_HIDDEN
;
192 extern HRESULT
get_decoder_info(REFCLSID clsid
, IWICBitmapDecoderInfo
**info
) DECLSPEC_HIDDEN
;
194 typedef struct BmpDecoder BmpDecoder
;
196 extern HRESULT
IcoDibDecoder_CreateInstance(BmpDecoder
**ppDecoder
) DECLSPEC_HIDDEN
;
197 extern void BmpDecoder_GetWICDecoder(BmpDecoder
*This
, IWICBitmapDecoder
**ppDecoder
) DECLSPEC_HIDDEN
;
198 extern void BmpDecoder_FindIconMask(BmpDecoder
*This
, ULONG
*mask_offset
, int *topdown
) DECLSPEC_HIDDEN
;
200 typedef struct _MetadataItem
207 typedef struct _MetadataHandlerVtbl
211 HRESULT (*fnLoad
)(IStream
*stream
, const GUID
*preferred_vendor
,
212 DWORD persist_options
, MetadataItem
**items
, DWORD
*item_count
);
213 HRESULT (*fnSave
)(IStream
*stream
, DWORD persist_options
,
214 const MetadataItem
*items
, DWORD item_count
);
215 HRESULT (*fnGetSizeMax
)(const MetadataItem
*items
, DWORD item_count
,
216 ULARGE_INTEGER
*size
);
217 } MetadataHandlerVtbl
;
219 extern HRESULT
MetadataReader_Create(const MetadataHandlerVtbl
*vtable
, REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
221 extern HRESULT
UnknownMetadataReader_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
222 extern HRESULT
IfdMetadataReader_CreateInstance(REFIID iid
, void **ppv
) DECLSPEC_HIDDEN
;
223 extern HRESULT
PngChrmReader_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
224 extern HRESULT
PngGamaReader_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
225 extern HRESULT
PngTextReader_CreateInstance(REFIID iid
, void** ppv
) DECLSPEC_HIDDEN
;
226 extern HRESULT
LSDReader_CreateInstance(REFIID iid
, void **ppv
) DECLSPEC_HIDDEN
;
227 extern HRESULT
IMDReader_CreateInstance(REFIID iid
, void **ppv
) DECLSPEC_HIDDEN
;
228 extern HRESULT
GCEReader_CreateInstance(REFIID iid
, void **ppv
) DECLSPEC_HIDDEN
;
229 extern HRESULT
APEReader_CreateInstance(REFIID iid
, void **ppv
) DECLSPEC_HIDDEN
;
230 extern HRESULT
GifCommentReader_CreateInstance(REFIID iid
, void **ppv
) DECLSPEC_HIDDEN
;
231 extern HRESULT
MetadataQueryReader_CreateInstance(IWICMetadataBlockReader
*, const WCHAR
*, IWICMetadataQueryReader
**) DECLSPEC_HIDDEN
;
232 extern HRESULT
stream_initialize_from_filehandle(IWICStream
*iface
, HANDLE hfile
) DECLSPEC_HIDDEN
;
234 static inline WCHAR
*heap_strdupW(const WCHAR
*src
)
238 if (!src
) return NULL
;
239 len
= (strlenW(src
) + 1) * sizeof(WCHAR
);
240 if ((dst
= HeapAlloc(GetProcessHeap(), 0, len
))) memcpy(dst
, src
, len
);
244 static inline const char *debug_wic_rect(const WICRect
*rect
)
246 if (!rect
) return "(null)";
247 return wine_dbg_sprintf("(%u,%u)-(%u,%u)", rect
->X
, rect
->Y
, rect
->Width
, rect
->Height
);
250 extern HMODULE windowscodecs_module
;
253 struct decoder_funcs
;
257 GUID container_format
;
262 #define DECODER_FLAGS_CAPABILITY_MASK 0x1f
277 WICColor palette
[256];
282 const struct decoder_funcs
*vtable
;
287 HRESULT (CDECL
*initialize
)(struct decoder
* This
, IStream
*stream
, struct decoder_stat
*st
);
288 HRESULT (CDECL
*get_frame_info
)(struct decoder
* This
, UINT frame
, struct decoder_frame
*info
);
289 HRESULT (CDECL
*copy_pixels
)(struct decoder
* This
, UINT frame
, const WICRect
*prc
,
290 UINT stride
, UINT buffersize
, BYTE
*buffer
);
291 void (CDECL
*destroy
)(struct decoder
* This
);
294 HRESULT CDECL
stream_read(IStream
*stream
, void *buffer
, ULONG read
, ULONG
*bytes_read
);
295 HRESULT CDECL
stream_seek(IStream
*stream
, LONGLONG ofs
, DWORD origin
, ULONGLONG
*new_position
);
299 HRESULT (CDECL
*stream_read
)(IStream
*stream
, void *buffer
, ULONG read
, ULONG
*bytes_read
);
300 HRESULT (CDECL
*stream_seek
)(IStream
*stream
, LONGLONG ofs
, DWORD origin
, ULONGLONG
*new_position
);
303 HRESULT CDECL
decoder_create(const CLSID
*decoder_clsid
, struct decoder_info
*info
, struct decoder
**result
);
304 HRESULT CDECL
decoder_initialize(struct decoder
*This
, IStream
*stream
, struct decoder_stat
*st
);
305 HRESULT CDECL
decoder_get_frame_info(struct decoder
* This
, UINT frame
, struct decoder_frame
*info
);
306 HRESULT CDECL
decoder_copy_pixels(struct decoder
* This
, UINT frame
, const WICRect
*prc
,
307 UINT stride
, UINT buffersize
, BYTE
*buffer
);
308 void CDECL
decoder_destroy(struct decoder
*This
);
310 HRESULT CDECL
png_decoder_create(struct decoder_info
*info
, struct decoder
**result
);
314 HRESULT (CDECL
*decoder_create
)(const CLSID
*decoder_clsid
, struct decoder_info
*info
, struct decoder
**result
);
315 HRESULT (CDECL
*decoder_initialize
)(struct decoder
*This
, IStream
*stream
, struct decoder_stat
*st
);
316 HRESULT (CDECL
*decoder_get_frame_info
)(struct decoder
* This
, UINT frame
, struct decoder_frame
*info
);
317 HRESULT (CDECL
*decoder_copy_pixels
)(struct decoder
* This
, UINT frame
, const WICRect
*prc
,
318 UINT stride
, UINT buffersize
, BYTE
*buffer
);
319 void (CDECL
*decoder_destroy
)(struct decoder
* This
);
322 HRESULT
get_unix_decoder(const CLSID
*decoder_clsid
, struct decoder_info
*info
, struct decoder
**result
);
324 #endif /* WINCODECS_PRIVATE_H */