ReactOS  0.4.15-dev-1386-g5cb9f87
jpegformat.c File Reference
#include "objbase.h"
#include "wincodec.h"
#include "wine/test.h"
Include dependency graph for jpegformat.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void test_decode_adobe_cmyk (void)
 
 START_TEST (jpegformat)
 

Variables

static const char jpeg_adobe_cmyk_1x5 []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 17 of file jpegformat.c.

Function Documentation

◆ START_TEST()

START_TEST ( jpegformat  )

Definition at line 138 of file jpegformat.c.

139 {
141 
143 
144  CoUninitialize();
145 }
static void test_decode_adobe_cmyk(void)
Definition: jpegformat.c:46
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
#define NULL
Definition: types.h:112

◆ test_decode_adobe_cmyk()

static void test_decode_adobe_cmyk ( void  )
static

Definition at line 46 of file jpegformat.c.

47 {
48  IWICBitmapDecoder *decoder;
49  IWICBitmapFrameDecode *framedecode;
50  HRESULT hr;
51  HGLOBAL hjpegdata;
52  char *jpegdata;
53  IStream *jpegstream;
54  GUID guidresult;
55  UINT count=0, width=0, height=0;
56  BYTE imagedata[5 * 4] = {1};
57  UINT i;
58 
59  const BYTE expected_imagedata[5 * 4] = {
60  0x00, 0xb0, 0xfc, 0x6d,
61  0x00, 0xb0, 0xfc, 0x6d,
62  0x00, 0xb0, 0xfc, 0x6d,
63  0x00, 0xb0, 0xfc, 0x6d,
64  0x00, 0xb0, 0xfc, 0x6d,
65  };
66 
67  const BYTE expected_imagedata_24bpp[5 * 4] = {
68  0x0d, 0x4b, 0x94, 0x00,
69  0x0d, 0x4b, 0x94, 0x00,
70  0x0d, 0x4b, 0x94, 0x00,
71  0x0d, 0x4b, 0x94, 0x00,
72  0x0d, 0x4b, 0x94, 0x00,
73  };
74 
75  hr = CoCreateInstance(&CLSID_WICJpegDecoder, NULL, CLSCTX_INPROC_SERVER,
76  &IID_IWICBitmapDecoder, (void**)&decoder);
77  ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
78  if (FAILED(hr)) return;
79 
80  hjpegdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(jpeg_adobe_cmyk_1x5));
81  ok(hjpegdata != 0, "GlobalAlloc failed\n");
82  if (hjpegdata)
83  {
84  jpegdata = GlobalLock(hjpegdata);
86  GlobalUnlock(hjpegdata);
87 
88  hr = CreateStreamOnHGlobal(hjpegdata, FALSE, &jpegstream);
89  ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr);
90  if (SUCCEEDED(hr))
91  {
92  hr = IWICBitmapDecoder_Initialize(decoder, jpegstream, WICDecodeMetadataCacheOnLoad);
93  ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
94 
95  hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult);
96  ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr);
97  ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatJpeg), "unexpected container format\n");
98 
99  hr = IWICBitmapDecoder_GetFrameCount(decoder, &count);
100  ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr);
101  ok(count == 1, "unexpected count %u\n", count);
102 
103  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
104  ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr);
105  if (SUCCEEDED(hr))
106  {
107  hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
108  ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr);
109  ok(width == 1, "expected width=1, got %u\n", width);
110  ok(height == 5, "expected height=5, got %u\n", height);
111 
112  hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
113  ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr);
114  ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat32bppCMYK) ||
115  broken(IsEqualGUID(&guidresult, &GUID_WICPixelFormat24bppBGR)), /* xp/2003 */
116  "unexpected pixel format: %s\n", wine_dbgstr_guid(&guidresult));
117 
118  /* We want to be sure our state tracking will not impact output
119  * data on subsequent calls */
120  for(i=2; i>0; --i)
121  {
122  hr = IWICBitmapFrameDecode_CopyPixels(framedecode, NULL, 4, sizeof(imagedata), imagedata);
123  ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
124  ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)) ||
125  broken(!memcmp(imagedata, expected_imagedata_24bpp, sizeof(expected_imagedata))), /* xp/2003 */
126  "unexpected image data\n");
127  }
128  IWICBitmapFrameDecode_Release(framedecode);
129  }
130  IStream_Release(jpegstream);
131  }
132  GlobalFree(hjpegdata);
133  }
134  IWICBitmapDecoder_Release(decoder);
135 }
GLint GLint GLsizei width
Definition: gl.h:1546
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
const char * wine_dbgstr_guid(const GUID *guid)
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM *ppstm)
#define FALSE
Definition: types.h:117
if SUCCEEDED(hr)
LONG HRESULT
Definition: typedefs.h:79
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
static const char jpeg_adobe_cmyk_1x5[]
Definition: jpegformat.c:23
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: xxhash.c:193
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define broken(x)
Definition: _sntprintf.h:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:51
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by START_TEST().

Variable Documentation

◆ jpeg_adobe_cmyk_1x5

const char jpeg_adobe_cmyk_1x5[]
static
Initial value:
=
"\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x01\x01\x2c"
"\x01\x2c\x00\x00\xff\xee\x00\x0e\x41\x64\x6f\x62\x65\x00\x64\x00"
"\x00\x00\x00\x02\xff\xfe\x00\x13\x43\x72\x65\x61\x74\x65\x64\x20"
"\x77\x69\x74\x68\x20\x47\x49\x4d\x50\xff\xdb\x00\x43\x00\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xdb"
"\x00\x43\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\xff\xc0\x00\x14\x08\x00\x05\x00\x01\x04\x01\x11\x00"
"\x02\x11\x01\x03\x11\x01\x04\x11\x00\xff\xc4\x00\x15\x00\x01\x01"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x08"
"\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\xff\xc4\x00\x14"
"\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\xff\xda\x00\x0e\x04\x01\x00\x02\x11\x03\x11\x04\x00\x00"
"\x3f\x00\x40\x44\x02\x1e\xa4\x1f\xff\xd9"

Definition at line 23 of file jpegformat.c.

Referenced by test_decode_adobe_cmyk().