ReactOS  0.4.14-dev-376-gaedba84
fliprotate.c File Reference
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
Include dependency graph for fliprotate.c:

Go to the source code of this file.

Classes

struct  FlipRotator
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct FlipRotator FlipRotator
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static FlipRotatorimpl_from_IWICBitmapFlipRotator (IWICBitmapFlipRotator *iface)
 
static HRESULT WINAPI FlipRotator_QueryInterface (IWICBitmapFlipRotator *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI FlipRotator_AddRef (IWICBitmapFlipRotator *iface)
 
static ULONG WINAPI FlipRotator_Release (IWICBitmapFlipRotator *iface)
 
static HRESULT WINAPI FlipRotator_GetSize (IWICBitmapFlipRotator *iface, UINT *puiWidth, UINT *puiHeight)
 
static HRESULT WINAPI FlipRotator_GetPixelFormat (IWICBitmapFlipRotator *iface, WICPixelFormatGUID *pPixelFormat)
 
static HRESULT WINAPI FlipRotator_GetResolution (IWICBitmapFlipRotator *iface, double *pDpiX, double *pDpiY)
 
static HRESULT WINAPI FlipRotator_CopyPalette (IWICBitmapFlipRotator *iface, IWICPalette *pIPalette)
 
static HRESULT WINAPI FlipRotator_CopyPixels (IWICBitmapFlipRotator *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
 
static HRESULT WINAPI FlipRotator_Initialize (IWICBitmapFlipRotator *iface, IWICBitmapSource *pISource, WICBitmapTransformOptions options)
 
HRESULT FlipRotator_Create (IWICBitmapFlipRotator **fliprotator)
 

Variables

static const IWICBitmapFlipRotatorVtbl FlipRotator_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file fliprotate.c.

Typedef Documentation

◆ FlipRotator

Function Documentation

◆ FlipRotator_AddRef()

static ULONG WINAPI FlipRotator_AddRef ( IWICBitmapFlipRotator iface)
static

Definition at line 74 of file fliprotate.c.

75 {
78 
79  TRACE("(%p) refcount=%u\n", iface, ref);
80 
81  return ref;
82 }
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ FlipRotator_CopyPalette()

static HRESULT WINAPI FlipRotator_CopyPalette ( IWICBitmapFlipRotator iface,
IWICPalette pIPalette 
)
static

Definition at line 142 of file fliprotate.c.

144 {
146  TRACE("(%p,%p)\n", iface, pIPalette);
147 
148  if (!This->source)
150  else
151  return IWICBitmapSource_CopyPalette(This->source, pIPalette);
152 }
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ FlipRotator_CopyPixels()

static HRESULT WINAPI FlipRotator_CopyPixels ( IWICBitmapFlipRotator iface,
const WICRect prc,
UINT  cbStride,
UINT  cbBufferSize,
BYTE pbBuffer 
)
static

Definition at line 154 of file fliprotate.c.

156 {
158  HRESULT hr;
159  UINT y;
160  UINT srcy, srcwidth, srcheight;
161  WICRect rc;
162  WICRect rect;
163 
164  TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
165 
166  if (!This->source) return WINCODEC_ERR_WRONGSTATE;
167 
168  if (This->swap_xy || This->flip_x)
169  {
170  /* This requires knowledge of the pixel format. */
171  FIXME("flipping x and rotating are not implemented\n");
172  return E_NOTIMPL;
173  }
174 
175  hr = IWICBitmapSource_GetSize(This->source, &srcwidth, &srcheight);
176  if (FAILED(hr)) return hr;
177 
178  if (!prc)
179  {
180  UINT width, height;
181  hr = IWICBitmapFlipRotator_GetSize(iface, &width, &height);
182  if (FAILED(hr)) return hr;
183  rect.X = 0;
184  rect.Y = 0;
185  rect.Width = width;
186  rect.Height = height;
187  prc = &rect;
188  }
189 
190  for (y=prc->Y; y - prc->Y < prc->Height; y++)
191  {
192  if (This->flip_y)
193  srcy = srcheight - 1 - y;
194  else
195  srcy = y;
196 
197  rc.X = prc->X;
198  rc.Y = srcy;
199  rc.Width = prc->Width;
200  rc.Height = 1;
201 
202  hr = IWICBitmapSource_CopyPixels(This->source, &rc, cbStride, cbStride,
203  pbBuffer);
204 
205  if (FAILED(hr)) break;
206 
207  pbBuffer += cbStride;
208  }
209 
210  return hr;
211 }
GLint GLint GLsizei width
Definition: gl.h:1546
HRESULT hr
Definition: shlfolder.c:183
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
& rect
Definition: startmenu.cpp:1413
#define FIXME(fmt,...)
Definition: debug.h:110
INT Height
Definition: wincodec.idl:239
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static const char * debug_wic_rect(const WICRect *rect)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
INT Width
Definition: wincodec.idl:238
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ FlipRotator_Create()

HRESULT FlipRotator_Create ( IWICBitmapFlipRotator **  fliprotator)

Definition at line 268 of file fliprotate.c.

269 {
270  FlipRotator *This;
271 
272  This = HeapAlloc(GetProcessHeap(), 0, sizeof(FlipRotator));
273  if (!This) return E_OUTOFMEMORY;
274 
275  This->IWICBitmapFlipRotator_iface.lpVtbl = &FlipRotator_Vtbl;
276  This->ref = 1;
277  This->source = NULL;
278  This->flip_x = 0;
279  This->flip_y = 0;
280  This->swap_xy = 0;
282  This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FlipRotator.lock");
283 
284  *fliprotator = &This->IWICBitmapFlipRotator_iface;
285 
286  return S_OK;
287 }
#define DWORD_PTR
Definition: treelist.c:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
static const IWICBitmapFlipRotatorVtbl FlipRotator_Vtbl
Definition: fliprotate.c:256
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59

Referenced by ImagingFactory_CreateBitmapFlipRotator().

◆ FlipRotator_GetPixelFormat()

static HRESULT WINAPI FlipRotator_GetPixelFormat ( IWICBitmapFlipRotator iface,
WICPixelFormatGUID pPixelFormat 
)
static

Definition at line 116 of file fliprotate.c.

118 {
120  TRACE("(%p,%p)\n", iface, pPixelFormat);
121 
122  if (!This->source)
124  else
125  return IWICBitmapSource_GetPixelFormat(This->source, pPixelFormat);
126 }
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ FlipRotator_GetResolution()

static HRESULT WINAPI FlipRotator_GetResolution ( IWICBitmapFlipRotator iface,
double pDpiX,
double pDpiY 
)
static

Definition at line 128 of file fliprotate.c.

130 {
132  TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
133 
134  if (!This->source)
136  else if (This->swap_xy)
137  return IWICBitmapSource_GetResolution(This->source, pDpiY, pDpiX);
138  else
139  return IWICBitmapSource_GetResolution(This->source, pDpiX, pDpiY);
140 }
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ FlipRotator_GetSize()

static HRESULT WINAPI FlipRotator_GetSize ( IWICBitmapFlipRotator iface,
UINT puiWidth,
UINT puiHeight 
)
static

Definition at line 102 of file fliprotate.c.

104 {
106  TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
107 
108  if (!This->source)
110  else if (This->swap_xy)
111  return IWICBitmapSource_GetSize(This->source, puiHeight, puiWidth);
112  else
113  return IWICBitmapSource_GetSize(This->source, puiWidth, puiHeight);
114 }
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ FlipRotator_Initialize()

static HRESULT WINAPI FlipRotator_Initialize ( IWICBitmapFlipRotator iface,
IWICBitmapSource pISource,
WICBitmapTransformOptions  options 
)
static

Definition at line 213 of file fliprotate.c.

215 {
217  HRESULT hr=S_OK;
218 
219  TRACE("(%p,%p,%u)\n", iface, pISource, options);
220 
221  EnterCriticalSection(&This->lock);
222 
223  if (This->source)
224  {
226  goto end;
227  }
228 
230  {
231  This->swap_xy = 1;
232  This->flip_x = !This->flip_x;
233  }
234 
236  {
237  This->flip_x = !This->flip_x;
238  This->flip_y = !This->flip_y;
239  }
240 
242  This->flip_x = !This->flip_x;
243 
245  This->flip_y = !This->flip_y;
246 
247  IWICBitmapSource_AddRef(pISource);
248  This->source = pISource;
249 
250 end:
251  LeaveCriticalSection(&This->lock);
252 
253  return hr;
254 }
HRESULT hr
Definition: shlfolder.c:183
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
GLuint GLuint end
Definition: gl.h:1545
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ FlipRotator_QueryInterface()

static HRESULT WINAPI FlipRotator_QueryInterface ( IWICBitmapFlipRotator iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 50 of file fliprotate.c.

52 {
54  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
55 
56  if (!ppv) return E_INVALIDARG;
57 
58  if (IsEqualIID(&IID_IUnknown, iid) ||
59  IsEqualIID(&IID_IWICBitmapSource, iid) ||
60  IsEqualIID(&IID_IWICBitmapFlipRotator, iid))
61  {
62  *ppv = &This->IWICBitmapFlipRotator_iface;
63  }
64  else
65  {
66  *ppv = NULL;
67  return E_NOINTERFACE;
68  }
69 
70  IUnknown_AddRef((IUnknown*)*ppv);
71  return S_OK;
72 }
#define E_NOINTERFACE
Definition: winerror.h:2364
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ FlipRotator_Release()

static ULONG WINAPI FlipRotator_Release ( IWICBitmapFlipRotator iface)
static

Definition at line 84 of file fliprotate.c.

85 {
88 
89  TRACE("(%p) refcount=%u\n", iface, ref);
90 
91  if (ref == 0)
92  {
93  This->lock.DebugInfo->Spare[0] = 0;
95  if (This->source) IWICBitmapSource_Release(This->source);
97  }
98 
99  return ref;
100 }
static FlipRotator * impl_from_IWICBitmapFlipRotator(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:45
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ impl_from_IWICBitmapFlipRotator()

static FlipRotator* impl_from_IWICBitmapFlipRotator ( IWICBitmapFlipRotator iface)
inlinestatic

Definition at line 45 of file fliprotate.c.

46 {
47  return CONTAINING_RECORD(iface, FlipRotator, IWICBitmapFlipRotator_iface);
48 }
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

Referenced by FlipRotator_AddRef(), FlipRotator_CopyPalette(), FlipRotator_CopyPixels(), FlipRotator_GetPixelFormat(), FlipRotator_GetResolution(), FlipRotator_GetSize(), FlipRotator_Initialize(), FlipRotator_QueryInterface(), and FlipRotator_Release().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ FlipRotator_Vtbl

const IWICBitmapFlipRotatorVtbl FlipRotator_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
Definition: fliprotate.c:154
static ULONG WINAPI FlipRotator_Release(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:84
static HRESULT WINAPI FlipRotator_CopyPalette(IWICBitmapFlipRotator *iface, IWICPalette *pIPalette)
Definition: fliprotate.c:142
static HRESULT WINAPI FlipRotator_GetSize(IWICBitmapFlipRotator *iface, UINT *puiWidth, UINT *puiHeight)
Definition: fliprotate.c:102
static HRESULT WINAPI FlipRotator_GetPixelFormat(IWICBitmapFlipRotator *iface, WICPixelFormatGUID *pPixelFormat)
Definition: fliprotate.c:116
static HRESULT WINAPI FlipRotator_QueryInterface(IWICBitmapFlipRotator *iface, REFIID iid, void **ppv)
Definition: fliprotate.c:50
static HRESULT WINAPI FlipRotator_GetResolution(IWICBitmapFlipRotator *iface, double *pDpiX, double *pDpiY)
Definition: fliprotate.c:128
static ULONG WINAPI FlipRotator_AddRef(IWICBitmapFlipRotator *iface)
Definition: fliprotate.c:74
static HRESULT WINAPI FlipRotator_Initialize(IWICBitmapFlipRotator *iface, IWICBitmapSource *pISource, WICBitmapTransformOptions options)
Definition: fliprotate.c:213

Definition at line 256 of file fliprotate.c.

Referenced by FlipRotator_Create().