ReactOS  0.4.14-dev-317-g96040ec
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 "config.h"
20 
21 #include <stdarg.h>
22 
23 #define COBJMACROS
24 
25 #include "windef.h"
26 #include "winbase.h"
27 #include "objbase.h"
28 
29 #include "wincodecs_private.h"
30 
31 #include "wine/debug.h"
32 
34 
35 typedef struct ColorTransform {
40 
42 {
43  return CONTAINING_RECORD(iface, ColorTransform, IWICColorTransform_iface);
44 }
45 
47  void **ppv)
48 {
50  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
51 
52  if (!ppv) return E_INVALIDARG;
53 
54  if (IsEqualIID(&IID_IUnknown, iid) ||
55  IsEqualIID(&IID_IWICBitmapSource, iid) ||
56  IsEqualIID(&IID_IWICColorTransform, iid))
57  {
58  *ppv = &This->IWICColorTransform_iface;
59  }
60  else
61  {
62  *ppv = NULL;
63  return E_NOINTERFACE;
64  }
65 
66  IUnknown_AddRef((IUnknown*)*ppv);
67  return S_OK;
68 }
69 
71 {
74 
75  TRACE("(%p) refcount=%u\n", iface, ref);
76 
77  return ref;
78 }
79 
81 {
84 
85  TRACE("(%p) refcount=%u\n", iface, ref);
86 
87  if (ref == 0)
88  {
89  if (This->dst) IWICBitmapSource_Release(This->dst);
91  }
92 
93  return ref;
94 }
95 
97  UINT *puiWidth, UINT *puiHeight)
98 {
100  TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
101 
102  return IWICBitmapSource_GetSize(This->dst, puiWidth, puiHeight);
103 }
104 
106  WICPixelFormatGUID *pPixelFormat)
107 {
109  TRACE("(%p,%p)\n", iface, pPixelFormat);
110 
111  return IWICBitmapSource_GetPixelFormat(This->dst, pPixelFormat);
112 }
113 
115  double *pDpiX, double *pDpiY)
116 {
118  TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
119 
120  return IWICBitmapSource_GetResolution(This->dst, pDpiX, pDpiY);
121 }
122 
124  IWICPalette *pIPalette)
125 {
127  TRACE("(%p,%p)\n", iface, pIPalette);
128 
129  return IWICBitmapSource_CopyPalette(This->dst, pIPalette);
130 }
131 
133  const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
134 {
136  TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
137 
138  return IWICBitmapSource_CopyPixels(This->dst, prc, cbStride, cbBufferSize, pbBuffer);
139 }
140 
142  IWICBitmapSource *pIBitmapSource, IWICColorContext *pIContextSource,
143  IWICColorContext *pIContextDest, REFWICPixelFormatGUID pixelFmtDest)
144 {
147  HRESULT hr;
148 
149  TRACE("(%p,%p,%p,%p,%s)\n", iface, pIBitmapSource, pIContextSource,
150  pIContextDest, debugstr_guid(pixelFmtDest));
151 
152  FIXME("ignoring color contexts\n");
153 
154  hr = WICConvertBitmapSource(pixelFmtDest, pIBitmapSource, &dst);
155  if (FAILED(hr)) return hr;
156 
157  if (This->dst) IWICBitmapSource_Release(This->dst);
158  This->dst = dst;
159  return S_OK;
160 }
161 
162 static const IWICColorTransformVtbl ColorTransform_Vtbl = {
172 };
173 
175 {
177 
178  if (!colortransform) return E_INVALIDARG;
179 
180  This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorTransform));
181  if (!This) return E_OUTOFMEMORY;
182 
183  This->IWICColorTransform_iface.lpVtbl = &ColorTransform_Vtbl;
184  This->ref = 1;
185  This->dst = NULL;
186 
187  *colortransform = &This->IWICColorTransform_iface;
188 
189  return S_OK;
190 }
IWICBitmapSource * dst
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
static HRESULT WINAPI ColorTransform_CopyPalette(IWICColorTransform *iface, IWICPalette *pIPalette)
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
static HRESULT WINAPI ColorTransform_GetResolution(IWICColorTransform *iface, double *pDpiX, double *pDpiY)
static ColorTransform * impl_from_IWICColorTransform(IWICColorTransform *iface)
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT ColorTransform_Create(IWICColorTransform **colortransform)
Definition: send.c:47
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static HRESULT WINAPI ColorTransform_CopyPixels(IWICColorTransform *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static const IWICColorTransformVtbl ColorTransform_Vtbl
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
struct ColorTransform ColorTransform
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HRESULT WINAPI ColorTransform_GetSize(IWICColorTransform *iface, UINT *puiWidth, UINT *puiHeight)
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI ColorTransform_GetPixelFormat(IWICColorTransform *iface, WICPixelFormatGUID *pPixelFormat)
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
static ULONG WINAPI ColorTransform_AddRef(IWICColorTransform *iface)
static ULONG WINAPI ColorTransform_Release(IWICColorTransform *iface)
#define InterlockedDecrement
Definition: armddk.h:52
static const char * debug_wic_rect(const WICRect *rect)
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
static HRESULT WINAPI ColorTransform_QueryInterface(IWICColorTransform *iface, REFIID iid, void **ppv)
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
static HRESULT WINAPI ColorTransform_Initialize(IWICColorTransform *iface, IWICBitmapSource *pIBitmapSource, IWICColorContext *pIContextSource, IWICColorContext *pIContextDest, REFWICPixelFormatGUID pixelFmtDest)
unsigned int ULONG
Definition: retypes.h:1
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2474
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs)
IWICColorTransform IWICColorTransform_iface
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define HeapFree(x, y, z)
Definition: compat.h:394
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95