ReactOS  0.4.15-dev-448-gd6c4411
colorcontext.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 colorcontext.c:

Go to the source code of this file.

Classes

struct  ColorContext
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct ColorContext ColorContext
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static ColorContextimpl_from_IWICColorContext (IWICColorContext *iface)
 
static HRESULT WINAPI ColorContext_QueryInterface (IWICColorContext *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI ColorContext_AddRef (IWICColorContext *iface)
 
static ULONG WINAPI ColorContext_Release (IWICColorContext *iface)
 
static HRESULT load_profile (const WCHAR *filename, BYTE **profile, UINT *len)
 
static HRESULT WINAPI ColorContext_InitializeFromFilename (IWICColorContext *iface, LPCWSTR wzFilename)
 
static HRESULT WINAPI ColorContext_InitializeFromMemory (IWICColorContext *iface, const BYTE *pbBuffer, UINT cbBufferSize)
 
static HRESULT WINAPI ColorContext_InitializeFromExifColorSpace (IWICColorContext *iface, UINT value)
 
static HRESULT WINAPI ColorContext_GetType (IWICColorContext *iface, WICColorContextType *pType)
 
static HRESULT WINAPI ColorContext_GetProfileBytes (IWICColorContext *iface, UINT cbBuffer, BYTE *pbBuffer, UINT *pcbActual)
 
static HRESULT WINAPI ColorContext_GetExifColorSpace (IWICColorContext *iface, UINT *pValue)
 
HRESULT ColorContext_Create (IWICColorContext **colorcontext)
 

Variables

static const IWICColorContextVtbl ColorContext_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file colorcontext.c.

Typedef Documentation

◆ ColorContext

Function Documentation

◆ ColorContext_AddRef()

static ULONG WINAPI ColorContext_AddRef ( IWICColorContext iface)
static

Definition at line 72 of file colorcontext.c.

73 {
76 
77  TRACE("(%p) refcount=%u\n", iface, ref);
78 
79  return ref;
80 }
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ ColorContext_Create()

HRESULT ColorContext_Create ( IWICColorContext **  colorcontext)

Definition at line 258 of file colorcontext.c.

259 {
261 
262  if (!colorcontext) return E_INVALIDARG;
263 
264  This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext));
265  if (!This) return E_OUTOFMEMORY;
266 
267  This->IWICColorContext_iface.lpVtbl = &ColorContext_Vtbl;
268  This->ref = 1;
269  This->type = 0;
270  This->profile = NULL;
271  This->profile_len = 0;
272  This->exif_color_space = ~0u;
273 
274  *colorcontext = &This->IWICColorContext_iface;
275 
276  return S_OK;
277 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const IWICColorContextVtbl ColorContext_Vtbl
Definition: colorcontext.c:246
#define S_OK
Definition: intsafe.h:59

Referenced by ImagingFactory_CreateColorContext().

◆ ColorContext_GetExifColorSpace()

static HRESULT WINAPI ColorContext_GetExifColorSpace ( IWICColorContext iface,
UINT pValue 
)
static

Definition at line 234 of file colorcontext.c.

236 {
238  TRACE("(%p,%p)\n", iface, pValue);
239 
240  if (!pValue) return E_INVALIDARG;
241 
242  *pValue = This->exif_color_space;
243  return S_OK;
244 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define S_OK
Definition: intsafe.h:59

◆ ColorContext_GetProfileBytes()

static HRESULT WINAPI ColorContext_GetProfileBytes ( IWICColorContext iface,
UINT  cbBuffer,
BYTE pbBuffer,
UINT pcbActual 
)
static

Definition at line 215 of file colorcontext.c.

217 {
219  TRACE("(%p,%u,%p,%p)\n", iface, cbBuffer, pbBuffer, pcbActual);
220 
221  if (This->type != WICColorContextProfile)
223 
224  if (!pcbActual) return E_INVALIDARG;
225 
226  if (cbBuffer >= This->profile_len && pbBuffer)
227  memcpy(pbBuffer, This->profile, This->profile_len);
228 
229  *pcbActual = This->profile_len;
230 
231  return S_OK;
232 }
#define WINCODEC_ERR_NOTINITIALIZED
Definition: winerror.h:3277
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define S_OK
Definition: intsafe.h:59

◆ ColorContext_GetType()

static HRESULT WINAPI ColorContext_GetType ( IWICColorContext iface,
WICColorContextType pType 
)
static

Definition at line 203 of file colorcontext.c.

205 {
207  TRACE("(%p,%p)\n", iface, pType);
208 
209  if (!pType) return E_INVALIDARG;
210 
211  *pType = This->type;
212  return S_OK;
213 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define S_OK
Definition: intsafe.h:59

◆ ColorContext_InitializeFromExifColorSpace()

static HRESULT WINAPI ColorContext_InitializeFromExifColorSpace ( IWICColorContext iface,
UINT  value 
)
static

Definition at line 188 of file colorcontext.c.

190 {
192  TRACE("(%p,%u)\n", iface, value);
193 
196 
197  This->exif_color_space = value;
199 
200  return S_OK;
201 }
#define TRACE(s)
Definition: solgame.cpp:4
GLsizei const GLfloat * value
Definition: glext.h:6069
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59

◆ ColorContext_InitializeFromFilename()

static HRESULT WINAPI ColorContext_InitializeFromFilename ( IWICColorContext iface,
LPCWSTR  wzFilename 
)
static

Definition at line 142 of file colorcontext.c.

144 {
146  BYTE *profile;
147  UINT len;
148  HRESULT hr;
149  TRACE("(%p,%s)\n", iface, debugstr_w(wzFilename));
150 
153 
154  if (!wzFilename) return E_INVALIDARG;
155 
156  hr = load_profile(wzFilename, &profile, &len);
157  if (FAILED(hr)) return hr;
158 
159  HeapFree(GetProcessHeap(), 0, This->profile);
160  This->profile = profile;
161  This->profile_len = len;
163 
164  return S_OK;
165 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT load_profile(const WCHAR *filename, BYTE **profile, UINT *len)
Definition: colorcontext.c:98
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
LONG HRESULT
Definition: typedefs.h:78
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
#define profile
Definition: kernel32.h:12
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ ColorContext_InitializeFromMemory()

static HRESULT WINAPI ColorContext_InitializeFromMemory ( IWICColorContext iface,
const BYTE pbBuffer,
UINT  cbBufferSize 
)
static

Definition at line 167 of file colorcontext.c.

169 {
171  BYTE *profile;
172  TRACE("(%p,%p,%u)\n", iface, pbBuffer, cbBufferSize);
173 
176 
177  if (!(profile = HeapAlloc(GetProcessHeap(), 0, cbBufferSize))) return E_OUTOFMEMORY;
178  memcpy(profile, pbBuffer, cbBufferSize);
179 
180  HeapFree(GetProcessHeap(), 0, This->profile);
181  This->profile = profile;
182  This->profile_len = cbBufferSize;
184 
185  return S_OK;
186 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: xxhash.c:193
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59
#define profile
Definition: kernel32.h:12
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ ColorContext_QueryInterface()

static HRESULT WINAPI ColorContext_QueryInterface ( IWICColorContext iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 49 of file colorcontext.c.

51 {
53  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
54 
55  if (!ppv) return E_INVALIDARG;
56 
57  if (IsEqualIID(&IID_IUnknown, iid) ||
58  IsEqualIID(&IID_IWICColorContext, iid))
59  {
60  *ppv = &This->IWICColorContext_iface;
61  }
62  else
63  {
64  *ppv = NULL;
65  return E_NOINTERFACE;
66  }
67 
68  IUnknown_AddRef((IUnknown*)*ppv);
69  return S_OK;
70 }
#define E_NOINTERFACE
Definition: winerror.h:2364
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
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ ColorContext_Release()

static ULONG WINAPI ColorContext_Release ( IWICColorContext iface)
static

Definition at line 82 of file colorcontext.c.

83 {
86 
87  TRACE("(%p) refcount=%u\n", iface, ref);
88 
89  if (ref == 0)
90  {
91  HeapFree(GetProcessHeap(), 0, This->profile);
93  }
94 
95  return ref;
96 }
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
#define InterlockedDecrement
Definition: armddk.h:52
static ColorContext * impl_from_IWICColorContext(IWICColorContext *iface)
Definition: colorcontext.c:44
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ impl_from_IWICColorContext()

static ColorContext* impl_from_IWICColorContext ( IWICColorContext iface)
inlinestatic

Definition at line 44 of file colorcontext.c.

45 {
46  return CONTAINING_RECORD(iface, ColorContext, IWICColorContext_iface);
47 }
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 ColorContext_AddRef(), ColorContext_GetExifColorSpace(), ColorContext_GetProfileBytes(), ColorContext_GetType(), ColorContext_InitializeFromExifColorSpace(), ColorContext_InitializeFromFilename(), ColorContext_InitializeFromMemory(), ColorContext_QueryInterface(), and ColorContext_Release().

◆ load_profile()

static HRESULT load_profile ( const WCHAR filename,
BYTE **  profile,
UINT len 
)
static

Definition at line 98 of file colorcontext.c.

99 {
100  HANDLE handle;
101  DWORD count;
103  BOOL ret;
104 
105  *len = 0;
106  *profile = NULL;
109 
110  if (!(GetFileSizeEx(handle, &size)))
111  {
114  }
115  if (size.u.HighPart)
116  {
117  WARN("file too large\n");
119  return E_FAIL;
120  }
121  if (!(*profile = HeapAlloc(GetProcessHeap(), 0, size.u.LowPart)))
122  {
124  return E_OUTOFMEMORY;
125  }
126  ret = ReadFile(handle, *profile, size.u.LowPart, &count, NULL);
128  if (!ret) {
130  *profile = NULL;
132  }
133  if (count != size.u.LowPart) {
135  *profile = NULL;
136  return E_FAIL;
137  }
138  *len = count;
139  return S_OK;
140 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define CloseHandle
Definition: compat.h:407
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
const char * filename
Definition: ioapi.h:135
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:435
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetFileSizeEx
Definition: compat.h:423
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
#define S_OK
Definition: intsafe.h:59
#define CreateFileW
Definition: compat.h:409
#define profile
Definition: kernel32.h:12
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by ColorContext_InitializeFromFilename().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ ColorContext_Vtbl

const IWICColorContextVtbl ColorContext_Vtbl
static
Initial value:
= {
}
static ULONG WINAPI ColorContext_AddRef(IWICColorContext *iface)
Definition: colorcontext.c:72
static ULONG WINAPI ColorContext_Release(IWICColorContext *iface)
Definition: colorcontext.c:82
static HRESULT WINAPI ColorContext_InitializeFromFilename(IWICColorContext *iface, LPCWSTR wzFilename)
Definition: colorcontext.c:142
static HRESULT WINAPI ColorContext_InitializeFromMemory(IWICColorContext *iface, const BYTE *pbBuffer, UINT cbBufferSize)
Definition: colorcontext.c:167
static HRESULT WINAPI ColorContext_QueryInterface(IWICColorContext *iface, REFIID iid, void **ppv)
Definition: colorcontext.c:49
static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface, WICColorContextType *pType)
Definition: colorcontext.c:203
static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface, UINT *pValue)
Definition: colorcontext.c:234
static HRESULT WINAPI ColorContext_InitializeFromExifColorSpace(IWICColorContext *iface, UINT value)
Definition: colorcontext.c:188
static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface, UINT cbBuffer, BYTE *pbBuffer, UINT *pcbActual)
Definition: colorcontext.c:215

Definition at line 246 of file colorcontext.c.

Referenced by ColorContext_Create().