ReactOS 0.4.16-dev-1028-g8602629
colortransform.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Hans Leidekker 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#include <stdarg.h>
20
21#define COBJMACROS
22
23#include "windef.h"
24#include "winbase.h"
25#include "objbase.h"
26
27#include "wincodecs_private.h"
28
29#include "wine/debug.h"
30
32
33typedef struct ColorTransform {
38
40{
41 return CONTAINING_RECORD(iface, ColorTransform, IWICColorTransform_iface);
42}
43
45 void **ppv)
46{
48 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
49
50 if (!ppv) return E_INVALIDARG;
51
52 if (IsEqualIID(&IID_IUnknown, iid) ||
53 IsEqualIID(&IID_IWICBitmapSource, iid) ||
54 IsEqualIID(&IID_IWICColorTransform, iid))
55 {
56 *ppv = &This->IWICColorTransform_iface;
57 }
58 else
59 {
60 *ppv = NULL;
61 return E_NOINTERFACE;
62 }
63
64 IUnknown_AddRef((IUnknown*)*ppv);
65 return S_OK;
66}
67
69{
72
73 TRACE("(%p) refcount=%lu\n", iface, ref);
74
75 return ref;
76}
77
79{
82
83 TRACE("(%p) refcount=%lu\n", iface, ref);
84
85 if (ref == 0)
86 {
87 if (This->dst) IWICBitmapSource_Release(This->dst);
88 free(This);
89 }
90
91 return ref;
92}
93
95 UINT *puiWidth, UINT *puiHeight)
96{
98 TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
99
100 return IWICBitmapSource_GetSize(This->dst, puiWidth, puiHeight);
101}
102
104 WICPixelFormatGUID *pPixelFormat)
105{
107 TRACE("(%p,%p)\n", iface, pPixelFormat);
108
109 return IWICBitmapSource_GetPixelFormat(This->dst, pPixelFormat);
110}
111
113 double *pDpiX, double *pDpiY)
114{
116 TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
117
118 return IWICBitmapSource_GetResolution(This->dst, pDpiX, pDpiY);
119}
120
122 IWICPalette *pIPalette)
123{
125 TRACE("(%p,%p)\n", iface, pIPalette);
126
127 return IWICBitmapSource_CopyPalette(This->dst, pIPalette);
128}
129
131 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
132{
134 TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
135
136 return IWICBitmapSource_CopyPixels(This->dst, prc, cbStride, cbBufferSize, pbBuffer);
137}
138
140 IWICBitmapSource *pIBitmapSource, IWICColorContext *pIContextSource,
141 IWICColorContext *pIContextDest, REFWICPixelFormatGUID pixelFmtDest)
142{
145 HRESULT hr;
146
147 TRACE("(%p,%p,%p,%p,%s)\n", iface, pIBitmapSource, pIContextSource,
148 pIContextDest, debugstr_guid(pixelFmtDest));
149
150 FIXME("ignoring color contexts\n");
151
152 hr = WICConvertBitmapSource(pixelFmtDest, pIBitmapSource, &dst);
153 if (FAILED(hr)) return hr;
154
155 if (This->dst) IWICBitmapSource_Release(This->dst);
156 This->dst = dst;
157 return S_OK;
158}
159
160static const IWICColorTransformVtbl ColorTransform_Vtbl = {
170};
171
173{
175
176 if (!colortransform) return E_INVALIDARG;
177
178 This = malloc(sizeof(ColorTransform));
179 if (!This) return E_OUTOFMEMORY;
180
181 This->IWICColorTransform_iface.lpVtbl = &ColorTransform_Vtbl;
182 This->ref = 1;
183 This->dst = NULL;
184
185 *colortransform = &This->IWICColorTransform_iface;
186
187 return S_OK;
188}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
static HRESULT WINAPI ColorTransform_GetResolution(IWICColorTransform *iface, double *pDpiX, double *pDpiY)
static HRESULT WINAPI ColorTransform_Initialize(IWICColorTransform *iface, IWICBitmapSource *pIBitmapSource, IWICColorContext *pIContextSource, IWICColorContext *pIContextDest, REFWICPixelFormatGUID pixelFmtDest)
static HRESULT WINAPI ColorTransform_CopyPalette(IWICColorTransform *iface, IWICPalette *pIPalette)
static HRESULT WINAPI ColorTransform_QueryInterface(IWICColorTransform *iface, REFIID iid, void **ppv)
static const IWICColorTransformVtbl ColorTransform_Vtbl
static ULONG WINAPI ColorTransform_Release(IWICColorTransform *iface)
static ULONG WINAPI ColorTransform_AddRef(IWICColorTransform *iface)
HRESULT ColorTransform_Create(IWICColorTransform **colortransform)
static ColorTransform * impl_from_IWICColorTransform(IWICColorTransform *iface)
static HRESULT WINAPI ColorTransform_GetPixelFormat(IWICColorTransform *iface, WICPixelFormatGUID *pPixelFormat)
static HRESULT WINAPI ColorTransform_GetSize(IWICColorTransform *iface, UINT *puiWidth, UINT *puiHeight)
static HRESULT WINAPI ColorTransform_CopyPixels(IWICColorTransform *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2437
GLenum GLenum dst
Definition: glext.h:6340
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
IWICColorTransform IWICColorTransform_iface
IWICBitmapSource * dst
Definition: scsiwmi.h:51
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
static const char * debug_wic_rect(const WICRect *rect)
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
unsigned char BYTE
Definition: xxhash.c:193