ReactOS 0.4.15-dev-7958-gcd0bb1a
metafile.c File Reference
#include <math.h>
#include "objbase.h"
#include "gdiplus.h"
#include "wine/test.h"
Include dependency graph for metafile.c:

Go to the source code of this file.

Classes

struct  emfplus_record
 
struct  emfplus_check_state
 
struct  EmfPlusRecordHeader
 
struct  MetafileImageObject
 

Macros

#define expect(expected, got)   ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 
#define expectf_(expected, got, precision)   ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
 
#define expectf(expected, got)   expectf_((expected), (got), 0.001)
 

Typedefs

typedef struct emfplus_record emfplus_record
 
typedef struct emfplus_check_state emfplus_check_state
 
typedef struct EmfPlusRecordHeader EmfPlusRecordHeader
 

Enumerations

enum  ObjectType {
  ObjectTypeInvalid , ObjectTypeBrush , ObjectTypePen , ObjectTypePath ,
  ObjectTypeRegion , ObjectTypeImage , ObjectTypeFont , ObjectTypeStringFormat ,
  ObjectTypeImageAttributes , ObjectTypeCustomLineCap
}
 
enum  ImageDataType {
  ImageDataTypeUnknown , ImageDataTypeBitmap , ImageDataTypeMetafile , ImageDataTypeUnknown ,
  ImageDataTypeBitmap , ImageDataTypeMetafile
}
 

Functions

static void check_record (int count, const char *desc, const struct emfplus_record *expected, const struct emfplus_record *actual)
 
static int CALLBACK enum_emf_proc (HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
 
static void check_emfplus (HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
 
static BOOL CALLBACK enum_metafile_proc (EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr, void *userdata)
 
static void check_metafile (GpMetafile *metafile, const emfplus_record *expected, const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
 
static BOOL CALLBACK play_metafile_proc (EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr, void *userdata)
 
static void play_metafile (GpMetafile *metafile, GpGraphics *graphics, const emfplus_record *expected, const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
 
static void sync_metafile (GpMetafile **metafile, const char *filename)
 
static void test_empty (void)
 
static void test_getdc (void)
 
static void test_emfonly (void)
 
static void test_fillrect (void)
 
static void test_clear (void)
 
static void test_nullframerect (void)
 
static void test_pagetransform (void)
 
static void test_worldtransform (void)
 
static void test_converttoemfplus (void)
 
static void test_frameunit (void)
 
static void test_containers (void)
 
static void test_clipping (void)
 
static void test_gditransform_cb (GpMetafile *metafile, EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr)
 
static void test_gditransform (void)
 
static void test_drawimage (void)
 
static void test_properties (void)
 
static void test_drawpath (void)
 
static void test_fillpath (void)
 
 START_TEST (metafile)
 

Variables

static BOOL save_metafiles
 
static BOOL load_metafiles
 
static const emfplus_record empty_records []
 
static const emfplus_record getdc_records []
 
static const emfplus_record emfonly_records []
 
static const emfplus_record emfonly_draw_records []
 
static const emfplus_record fillrect_records []
 
static const emfplus_record clear_emf_records []
 
static const emfplus_record pagetransform_records []
 
static const emfplus_record worldtransform_records []
 
static const emfplus_record container_records []
 
static const emfplus_record clipping_records []
 
static const emfplus_record gditransform_records []
 
static const emfplus_record draw_image_bitmap_records []
 
static const emfplus_record draw_image_metafile_records []
 
static const emfplus_record properties_records []
 
static const emfplus_record draw_path_records []
 
static const emfplus_record fill_path_records []
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)

Definition at line 27 of file metafile.c.

◆ expectf

#define expectf (   expected,
  got 
)    expectf_((expected), (got), 0.001)

Definition at line 29 of file metafile.c.

◆ expectf_

#define expectf_ (   expected,
  got,
  precision 
)    ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))

Definition at line 28 of file metafile.c.

Typedef Documentation

◆ emfplus_check_state

◆ emfplus_record

◆ EmfPlusRecordHeader

Enumeration Type Documentation

◆ ImageDataType

Enumerator
ImageDataTypeUnknown 
ImageDataTypeBitmap 
ImageDataTypeMetafile 
ImageDataTypeUnknown 
ImageDataTypeBitmap 
ImageDataTypeMetafile 

Definition at line 94 of file metafile.c.

95{
ImageDataType
Definition: metafile.c:355
@ ImageDataTypeBitmap
Definition: metafile.c:357
@ ImageDataTypeUnknown
Definition: metafile.c:356
@ ImageDataTypeMetafile
Definition: metafile.c:358

◆ ObjectType

Enumerator
ObjectTypeInvalid 
ObjectTypeBrush 
ObjectTypePen 
ObjectTypePath 
ObjectTypeRegion 
ObjectTypeImage 
ObjectTypeFont 
ObjectTypeStringFormat 
ObjectTypeImageAttributes 
ObjectTypeCustomLineCap 

Definition at line 80 of file metafile.c.

81{
@ ObjectTypeImage
@ ObjectTypeInvalid
@ ObjectTypeImageAttributes
@ ObjectTypePen
@ ObjectTypeFont
@ ObjectTypeRegion
@ ObjectTypeBrush
@ ObjectTypePath
ObjectType
Definition: metafile.c:81
@ ObjectTypeStringFormat
Definition: metafile.c:89
@ ObjectTypeCustomLineCap
Definition: metafile.c:91

Function Documentation

◆ check_emfplus()

static void check_emfplus ( HENHMETAFILE  hemf,
const emfplus_record expected,
const char desc 
)
static

Definition at line 198 of file metafile.c.

199{
201
202 state.desc = desc;
203 state.count = 0;
204 state.expected = expected;
205
207
208 todo_wine_if (expected[state.count].todo)
209 ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
210}
static int state
Definition: maze.c:121
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static const WCHAR desc[]
Definition: protectdata.c:36
BOOL expected
Definition: store.c:2063
static int CALLBACK enum_emf_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
Definition: metafile.c:113
#define todo_wine_if(is_todo)
Definition: custom.c:76
BOOL WINAPI EnumEnhMetaFile(_In_opt_ HDC, _In_ HENHMETAFILE, _In_ ENHMFENUMPROC, _In_opt_ PVOID, _In_opt_ LPCRECT)

Referenced by test_clear(), test_drawimage(), test_drawpath(), test_emfonly(), test_empty(), test_fillpath(), test_getdc(), and test_properties().

◆ check_metafile()

static void check_metafile ( GpMetafile metafile,
const emfplus_record expected,
const char desc,
const GpPointF dst_points,
const GpRectF src_rect,
Unit  src_unit 
)
static

Definition at line 239 of file metafile.c.

241{
243 HDC hdc;
244 GpGraphics *graphics;
246
247 state.desc = desc;
248 state.count = 0;
249 state.expected = expected;
250 state.metafile = metafile;
251
253
254 stat = GdipCreateFromHDC(hdc, &graphics);
255 expect(Ok, stat);
256
258 3, src_rect, src_unit, enum_metafile_proc, &state, NULL);
259 expect(Ok, stat);
260
261 todo_wine_if (expected[state.count].todo)
262 ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count);
263
264 GdipDeleteGraphics(graphics);
265
266 DeleteDC(hdc);
267}
#define stat
Definition: acwin.h:99
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
static int CALLBACK enum_metafile_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
Definition: metafile.c:3385
GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPoints(GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST GpPointF *destPoints, INT count, GDIPCONST GpRectF *srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes)
Definition: metafile.c:3435
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define expect(expected, got)
Definition: metafile.c:27
static const unsigned char metafile[]
Definition: olepicture.c:138
Definition: stat.h:55
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by test_clipping(), test_containers(), test_emfonly(), test_empty(), test_fillrect(), test_gditransform(), test_getdc(), test_pagetransform(), and test_worldtransform().

◆ check_record()

static void check_record ( int  count,
const char desc,
const struct emfplus_record expected,
const struct emfplus_record actual 
)
static

Definition at line 53 of file metafile.c.

54{
56 {
58 ok(expected->record_type == actual->record_type && (expected->flags == actual->flags ||
59 broken(expected->broken_flags == actual->flags)),
60 "%s.%i: Expected record type 0x%x, got 0x%x. Expected flags %#x, got %#x.\n", desc, count,
61 expected->record_type, actual->record_type, expected->flags, actual->flags);
62 }
63 else
64 {
65 todo_wine_if (expected->todo)
66 ok(expected->record_type == actual->record_type,
67 "%s.%i: Expected record type 0x%x, got 0x%x.\n", desc, count,
68 expected->record_type, actual->record_type);
69 }
70}
BOOLEAN Expected
#define broken(x)
Definition: _sntprintf.h:21
#define GDIP_EMFPLUS_RECORD_BASE
Definition: gdiplusenums.h:450
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLbitfield flags
Definition: glext.h:7161
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
DWORD record_type
Definition: metafile.c:36

◆ enum_emf_proc()

static int CALLBACK enum_emf_proc ( HDC  hDC,
HANDLETABLE lpHTable,
const ENHMETARECORD lpEMFR,
int  nObj,
LPARAM  lpData 
)
static

Definition at line 113 of file metafile.c.

115{
117 emfplus_record actual;
118
119 if (lpEMFR->iType == EMR_GDICOMMENT)
120 {
121 const EMRGDICOMMENT *comment = (const EMRGDICOMMENT*)lpEMFR;
122
123 if (comment->cbData >= 4 && memcmp(comment->Data, "EMF+", 4) == 0)
124 {
125 int offset = 4;
126
127 while (offset + sizeof(EmfPlusRecordHeader) <= comment->cbData)
128 {
130
131 ok(record->Size == record->DataSize + sizeof(EmfPlusRecordHeader),
132 "%s: EMF+ record datasize %u and size %u mismatch\n", state->desc, record->DataSize, record->Size);
133
134 ok(offset + record->DataSize <= comment->cbData,
135 "%s: EMF+ record truncated\n", state->desc);
136
137 if (offset + record->DataSize > comment->cbData)
138 return 0;
139
140 if (state->expected[state->count].record_type)
141 {
142 actual.todo = FALSE;
143 actual.record_type = record->Type;
144 actual.flags = record->Flags;
145
146 check_record(state->count, state->desc, &state->expected[state->count], &actual);
147 state->count++;
148
149 if (state->expected[state->count-1].todo && state->expected[state->count-1].record_type != actual.record_type)
150 continue;
151 }
152 else
153 {
154 ok(0, "%s: Unexpected EMF+ 0x%x record\n", state->desc, record->Type);
155 }
156
157 if ((record->Flags >> 8) == ObjectTypeImage && record->Type == EmfPlusRecordTypeObject)
158 {
160
161 if (image->Type == ImageDataTypeMetafile)
162 {
163 HENHMETAFILE hemf = SetEnhMetaFileBits(image->MetafileDataSize, image->MetafileData);
164 ok(hemf != NULL, "%s: SetEnhMetaFileBits failed\n", state->desc);
165
167 DeleteEnhMetaFile(hemf);
168 }
169 }
170
171 offset += record->Size;
172 }
173
174 ok(offset == comment->cbData, "%s: truncated EMF+ record data?\n", state->desc);
175
176 return 1;
177 }
178 }
179
180 if (state->expected[state->count].record_type)
181 {
182 actual.todo = FALSE;
183 actual.record_type = lpEMFR->iType;
184 actual.flags = 0;
185
186 check_record(state->count, state->desc, &state->expected[state->count], &actual);
187
188 state->count++;
189 }
190 else
191 {
192 ok(0, "%s: Unexpected EMF 0x%x record\n", state->desc, lpEMFR->iType);
193 }
194
195 return 1;
196}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define check_record(rec,...)
Definition: db.c:62
#define FALSE
Definition: types.h:117
@ EmfPlusRecordTypeObject
Definition: gdiplusenums.h:667
GLintptr offset
Definition: glext.h:5920
#define comment(fmt, arg1)
Definition: rebar.c:820
DWORD flags
Definition: metafile.c:37
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
#define EMR_GDICOMMENT
Definition: wingdi.h:143

Referenced by check_emfplus(), and enum_emf_proc().

◆ enum_metafile_proc()

static BOOL CALLBACK enum_metafile_proc ( EmfPlusRecordType  record_type,
unsigned int  flags,
unsigned int  dataSize,
const unsigned char pStr,
void userdata 
)
static

Definition at line 212 of file metafile.c.

214{
216 emfplus_record actual;
217
218 actual.todo = FALSE;
219 actual.record_type = record_type;
220 actual.flags = flags;
221
222 if (dataSize == 0)
223 ok(pStr == NULL, "non-NULL pStr\n");
224
225 if (state->expected[state->count].record_type)
226 {
227 check_record(state->count, state->desc, &state->expected[state->count], &actual);
228
229 state->count++;
230 }
231 else
232 {
233 ok(0, "%s: Unexpected EMF 0x%x record\n", state->desc, record_type);
234 }
235
236 return TRUE;
237}
#define TRUE
Definition: types.h:120
GLenum GLsizei dataSize
Definition: glext.h:11123

◆ play_metafile()

static void play_metafile ( GpMetafile metafile,
GpGraphics graphics,
const emfplus_record expected,
const char desc,
const GpPointF dst_points,
const GpRectF src_rect,
Unit  src_unit 
)
static

Definition at line 305 of file metafile.c.

307{
310
311 state.desc = desc;
312 state.count = 0;
313 state.expected = expected;
314 state.metafile = metafile;
315
317 3, src_rect, src_unit, play_metafile_proc, &state, NULL);
318 expect(Ok, stat);
319}
static BOOL CALLBACK play_metafile_proc(EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr, void *userdata)
Definition: metafile.c:269

Referenced by test_clipping(), test_containers(), test_emfonly(), test_fillrect(), test_gditransform(), test_getdc(), test_pagetransform(), and test_worldtransform().

◆ play_metafile_proc()

static BOOL CALLBACK play_metafile_proc ( EmfPlusRecordType  record_type,
unsigned int  flags,
unsigned int  dataSize,
const unsigned char pStr,
void userdata 
)
static

Definition at line 269 of file metafile.c.

271{
274
275 if (state->expected[state->count].record_type)
276 {
277 BOOL match = (state->expected[state->count].record_type == record_type);
278
279 if (match && state->expected[state->count].playback_fn)
280 state->expected[state->count].playback_fn(state->metafile, record_type, flags, dataSize, pStr);
281 else
282 {
283 stat = GdipPlayMetafileRecord(state->metafile, record_type, flags, dataSize, pStr);
284 todo_wine_if (state->expected[state->count].playback_todo)
285 ok(stat == Ok, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state->desc, state->count, stat);
286 }
287
289 ok(state->expected[state->count].record_type == record_type,
290 "%s.%i: expected record type 0x%x, got 0x%x\n", state->desc, state->count,
291 state->expected[state->count].record_type, record_type);
292 state->count++;
293 }
294 else
295 {
296 todo_wine_if (state->expected[state->count].playback_todo)
297 ok(0, "%s: unexpected record 0x%x\n", state->desc, record_type);
298
300 }
301
302 return TRUE;
303}
return
Definition: dirsup.c:529
GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, EmfPlusRecordType recordType, UINT flags, UINT dataSize, GDIPCONST BYTE *data)
Definition: metafile.c:2461
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
_CRTIMP void __cdecl unexpected(void)
BOOL todo
Definition: filedlg.c:313
Definition: match.c:28
else
Definition: tritemp.h:161

Referenced by play_metafile().

◆ START_TEST()

START_TEST ( metafile  )

Definition at line 2787 of file metafile.c.

2788{
2789 struct GdiplusStartupInput gdiplusStartupInput;
2790 ULONG_PTR gdiplusToken;
2791 int myARGC;
2792 char **myARGV;
2793 HMODULE hmsvcrt;
2794 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
2795
2796 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
2797 hmsvcrt = LoadLibraryA("msvcrt");
2798 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
2799 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
2800
2801 gdiplusStartupInput.GdiplusVersion = 1;
2802 gdiplusStartupInput.DebugEventCallback = NULL;
2803 gdiplusStartupInput.SuppressBackgroundThread = 0;
2804 gdiplusStartupInput.SuppressExternalCodecs = 0;
2805
2806 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2807
2809
2810 if (myARGC >= 3)
2811 {
2812 if (!strcmp(myARGV[2], "save"))
2814 else if (!strcmp(myARGV[2], "load"))
2816 }
2817
2818 test_empty();
2819 test_getdc();
2820 test_emfonly();
2821 test_fillrect();
2822 test_clear();
2829 test_clipping();
2833 test_drawpath();
2834 test_fillpath();
2835
2836 GdiplusShutdown(gdiplusToken);
2837}
static INT myARGC
Definition: FindFiles.c:29
static LPSTR * myARGV
Definition: FindFiles.c:30
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: _controlfp_s.c:19
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
void WINAPI GdiplusShutdown(ULONG_PTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_clear(void)
Definition: metafile.c:1143
static void test_containers(void)
Definition: metafile.c:1986
static void test_clipping(void)
Definition: metafile.c:2180
static void test_worldtransform(void)
Definition: metafile.c:1556
static void test_gditransform(void)
Definition: metafile.c:2324
static void test_pagetransform(void)
Definition: metafile.c:1351
static void test_fillrect(void)
Definition: metafile.c:1029
static BOOL save_metafiles
Definition: metafile.c:31
static void test_getdc(void)
Definition: metafile.c:573
static BOOL load_metafiles
Definition: metafile.c:32
static void test_nullframerect(void)
Definition: metafile.c:1219
static void test_fillpath(void)
Definition: metafile.c:2717
static void test_drawpath(void)
Definition: metafile.c:2652
static void test_empty(void)
Definition: metafile.c:368
static void test_properties(void)
Definition: metafile.c:2574
static void test_emfonly(void)
Definition: metafile.c:728
static void test_frameunit(void)
Definition: metafile.c:1894
static void test_drawimage(void)
Definition: metafile.c:2459
static void test_converttoemfplus(void)
Definition: metafile.c:1816
int winetest_get_mainargs(char ***pargv)
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ sync_metafile()

static void sync_metafile ( GpMetafile **  metafile,
const char filename 
)
static

Definition at line 323 of file metafile.c.

324{
326 if (save_metafiles)
327 {
328 GpMetafile *clone;
329 HENHMETAFILE hemf;
330
331 stat = GdipCloneImage((GpImage*)*metafile, (GpImage**)&clone);
332 expect(Ok, stat);
333
334 stat = GdipGetHemfFromMetafile(clone, &hemf);
335 expect(Ok, stat);
336
338
339 DeleteEnhMetaFile(hemf);
340
341 stat = GdipDisposeImage((GpImage*)clone);
342 expect(Ok, stat);
343 }
344 else if (load_metafiles)
345 {
346 HENHMETAFILE hemf;
347
349 expect(Ok, stat);
350 *metafile = NULL;
351
353 ok(hemf != NULL, "%s could not be opened\n", filename);
354
356 expect(Ok, stat);
357 }
358}
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155
GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
Definition: image.c:1308
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile)
Definition: metafile.c:3804
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
const char * filename
Definition: ioapi.h:137
HENHMETAFILE WINAPI GetEnhMetaFileA(_In_ LPCSTR)
HENHMETAFILE WINAPI CopyEnhMetaFileA(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCSTR pszFile)

Referenced by test_clear(), test_clipping(), test_containers(), test_drawimage(), test_drawpath(), test_emfonly(), test_empty(), test_fillpath(), test_fillrect(), test_gditransform(), test_getdc(), test_pagetransform(), test_properties(), and test_worldtransform().

◆ test_clear()

static void test_clear ( void  )
static

Definition at line 1143 of file metafile.c.

1144{
1145 GpStatus stat;
1147 GpGraphics *graphics;
1148 HDC hdc;
1149 HENHMETAFILE hemf;
1150 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1151 static const GpPointF dst_points[3] = {{10.0,10.0},{20.0,10.0},{10.0,20.0}};
1152 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1154 ARGB color;
1155
1157
1159 expect(Ok, stat);
1160
1161 DeleteDC(hdc);
1162
1163 if (stat != Ok)
1164 return;
1165
1168
1170 expect(Ok, stat);
1171
1172 stat = GdipGraphicsClear(graphics, 0xffffff00);
1173 expect(Ok, stat);
1174
1175 stat = GdipDeleteGraphics(graphics);
1176 expect(Ok, stat);
1177
1178 sync_metafile(&metafile, "clear.emf");
1179
1181 expect(Ok, stat);
1182
1184 expect(Ok, stat);
1185
1186 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
1187 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
1188 expect(Ok, stat);
1189
1191 expect(Ok, stat);
1192 expect(0xff000000, color);
1193
1194 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1195 expect(Ok, stat);
1196 expect(0xffffff00, color);
1197
1198 stat = GdipBitmapGetPixel(bitmap, 25, 25, &color);
1199 expect(Ok, stat);
1200 expect(0xff000000, color);
1201
1202 stat = GdipDeleteGraphics(graphics);
1203 expect(Ok, stat);
1204
1206 expect(Ok, stat);
1207
1209 expect(Ok, stat);
1210
1212 expect(Ok, stat);
1213
1214 check_emfplus(hemf, clear_emf_records, "clear emf");
1215
1216 DeleteEnhMetaFile(hemf);
1217}
GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
Definition: graphics.c:5076
GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image, GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, VOID *callbackData)
Definition: graphics.c:3071
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2249
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
@ EmfTypeEmfPlusOnly
Definition: gdiplusenums.h:235
@ UnitPixel
Definition: gdiplusenums.h:29
@ MetafileFrameUnitPixel
Definition: gdiplusenums.h:381
DWORD ARGB
#define PixelFormat32bppRGB
@ InvalidParameter
Definition: gdiplustypes.h:28
GLuint color
Definition: glext.h:6243
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
static const emfplus_record clear_emf_records[]
Definition: metafile.c:1130
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
Definition: uimain.c:89
const char * description
Definition: directx.c:2497
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_clipping()

static void test_clipping ( void  )
static

Definition at line 2180 of file metafile.c.

2181{
2182 GpStatus stat;
2184 GpGraphics *graphics;
2186 GpRegion *region;
2187 GpBrush *brush;
2188 GpRectF rect;
2189 ARGB color;
2190 HDC hdc;
2191 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2192 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
2193 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
2195
2197
2199 expect(Ok, stat);
2200
2201 DeleteDC(hdc);
2202
2203 if (stat != Ok)
2204 return;
2205
2207 expect(Ok, stat);
2208
2209 stat = GdipSaveGraphics(graphics, &state);
2210 expect(Ok, stat);
2211
2212 stat = GdipGetVisibleClipBounds(graphics, &rect);
2213 expect(Ok, stat);
2214 ok(rect.X == -0x400000, "rect.X = %f\n", rect.X);
2215 ok(rect.Y == -0x400000, "rect.Y = %f\n", rect.Y);
2216 ok(rect.Width == 0x800000, "rect.Width = %f\n", rect.Width);
2217 ok(rect.Height == 0x800000, "rect.Height = %f\n", rect.Height);
2218
2219 stat = GdipSetClipRect(graphics, 30, 30, 10, 10, CombineModeReplace);
2220 expect(Ok, stat);
2221
2222 stat = GdipGetVisibleClipBounds(graphics, &rect);
2223 expect(Ok, stat);
2224 ok(rect.X == 30, "rect.X = %f\n", rect.X);
2225 ok(rect.Y == 30, "rect.Y = %f\n", rect.Y);
2226 ok(rect.Width == 10, "rect.Width = %f\n", rect.Width);
2227 ok(rect.Height == 10, "rect.Height = %f\n", rect.Height);
2228
2229 stat = GdipCreateSolidFill((ARGB)0xff000000, (GpSolidFill**)&brush);
2230 expect(Ok, stat);
2231
2232 stat = GdipFillRectangle(graphics, brush, 0, 0, 100, 100);
2233 expect(Ok, stat);
2234
2235 stat = GdipDeleteBrush(brush);
2236 expect(Ok, stat);
2237
2238 stat = GdipRestoreGraphics(graphics, state);
2239 expect(Ok, stat);
2240
2241 stat = GdipSetClipRect(graphics, 30, 30, 10, 10, CombineModeXor);
2242 expect(Ok, stat);
2243
2244 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
2245 expect(Ok, stat);
2246
2247 stat = GdipFillRectangle(graphics, brush, 30, 30, 20, 10);
2248 expect(Ok, stat);
2249
2250 stat = GdipDeleteBrush(brush);
2251 expect(Ok, stat);
2252
2253 stat = GdipCreateRegionRect(&rect, &region);
2254 expect(Ok, stat);
2255
2256 stat = GdipSetClipRegion(graphics, region, CombineModeIntersect);
2257 expect(Ok, stat);
2258
2259 stat = GdipDeleteRegion(region);
2260 expect(Ok, stat);
2261
2262 stat = GdipDeleteGraphics(graphics);
2263 expect(Ok, stat);
2264
2265 check_metafile(metafile, clipping_records, "clipping metafile", dst_points, &frame, UnitPixel);
2266
2267 sync_metafile(&metafile, "clipping.emf");
2268
2270 expect(Ok, stat);
2271
2273 expect(Ok, stat);
2274
2275 play_metafile(metafile, graphics, clipping_records, "clipping playback", dst_points, &frame, UnitPixel);
2276
2277 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
2278 expect(Ok, stat);
2279 expect(0, color);
2280
2281 stat = GdipBitmapGetPixel(bitmap, 35, 35, &color);
2282 expect(Ok, stat);
2283 expect(0xff000000, color);
2284
2285 stat = GdipBitmapGetPixel(bitmap, 45, 35, &color);
2286 expect(Ok, stat);
2287 expect(0xff0000ff, color);
2288
2289 stat = GdipDeleteGraphics(graphics);
2290 expect(Ok, stat);
2291
2293 expect(Ok, stat);
2294
2296 expect(Ok, stat);
2297}
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:994
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:757
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, CombineMode mode)
Definition: graphics.c:6533
GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode mode)
Definition: graphics.c:6473
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics *graphics, GpRectF *rect)
Definition: graphics.c:5004
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
Definition: graphics.c:5911
GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4537
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
Definition: graphics.c:6045
GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
Definition: region.c:459
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
Definition: region.c:571
@ CombineModeReplace
Definition: gdiplusenums.h:351
@ CombineModeIntersect
Definition: gdiplusenums.h:352
@ CombineModeXor
Definition: gdiplusenums.h:354
UINT GraphicsState
Definition: gdiplusenums.h:22
#define PixelFormat32bppARGB
static const emfplus_record clipping_records[]
Definition: metafile.c:2164
static void play_metafile(GpMetafile *metafile, GpGraphics *graphics, const emfplus_record *expected, const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
Definition: metafile.c:305
static void check_metafile(GpMetafile *metafile, const emfplus_record *expected, const char *desc, const GpPointF *dst_points, const GpRectF *src_rect, Unit src_unit)
Definition: metafile.c:239
& rect
Definition: startmenu.cpp:1413

Referenced by START_TEST().

◆ test_containers()

static void test_containers ( void  )
static

Definition at line 1986 of file metafile.c.

1987{
1988 GpStatus stat;
1990 GpGraphics *graphics;
1992 GpBrush *brush;
1993 ARGB color;
1994 HDC hdc;
1995 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1996 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1997 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1998 GraphicsContainer state1, state2;
1999 GpRectF srcrect, dstrect;
2000 REAL dpix, dpiy;
2001
2003
2005 expect(Ok, stat);
2006
2007 DeleteDC(hdc);
2008
2009 if (stat != Ok)
2010 return;
2011
2013 expect(Ok, stat);
2014
2015 /* Normal usage */
2016 stat = GdipBeginContainer2(graphics, &state1);
2017 expect(Ok, stat);
2018
2019 stat = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
2020 expect(Ok, stat);
2021
2022 stat = GdipCreateSolidFill((ARGB)0xff000000, (GpSolidFill**)&brush);
2023 expect(Ok, stat);
2024
2025 stat = GdipFillRectangle(graphics, brush, 5.0, 5.0, 5.0, 5.0);
2026 expect(Ok, stat);
2027
2028 stat = GdipDeleteBrush(brush);
2029 expect(Ok, stat);
2030
2031 stat = GdipEndContainer(graphics, state1);
2032 expect(Ok, stat);
2033
2034 stat = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
2035 expect(Ok, stat);
2036
2037 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
2038 expect(Ok, stat);
2039
2040 stat = GdipFillRectangle(graphics, brush, 5.0, 5.0, 5.0, 5.0);
2041 expect(Ok, stat);
2042
2043 stat = GdipDeleteBrush(brush);
2044 expect(Ok, stat);
2045
2046 stat = GdipSaveGraphics(graphics, &state1);
2047 expect(Ok, stat);
2048
2049 stat = GdipRestoreGraphics(graphics, state1);
2050 expect(Ok, stat);
2051
2052 /* Popping two states at once */
2053 stat = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
2054 expect(Ok, stat);
2055
2056 stat = GdipBeginContainer2(graphics, &state1);
2057 expect(Ok, stat);
2058
2059 stat = GdipScaleWorldTransform(graphics, 4.0, 4.0, MatrixOrderPrepend);
2060 expect(Ok, stat);
2061
2062 stat = GdipBeginContainer2(graphics, &state2);
2063 expect(Ok, stat);
2064
2065 stat = GdipEndContainer(graphics, state1);
2066 expect(Ok, stat);
2067
2068 stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
2069 expect(Ok, stat);
2070
2071 stat = GdipFillRectangle(graphics, brush, 20.0, 20.0, 5.0, 5.0);
2072 expect(Ok, stat);
2073
2074 stat = GdipDeleteBrush(brush);
2075 expect(Ok, stat);
2076
2077 /* With transform applied */
2078 stat = GdipGetDpiX(graphics, &dpix);
2079 expect(Ok, stat);
2080
2081 stat = GdipGetDpiY(graphics, &dpiy);
2082 expect(Ok, stat);
2083
2084 srcrect.X = 0.0;
2085 srcrect.Y = 0.0;
2086 srcrect.Width = 1.0;
2087 srcrect.Height = 1.0;
2088
2089 dstrect.X = 25.0;
2090 dstrect.Y = 0.0;
2091 dstrect.Width = 5.0;
2092 dstrect.Height = 5.0;
2093
2094 stat = GdipBeginContainer(graphics, &dstrect, &srcrect, UnitInch, &state1);
2095 expect(Ok, stat);
2096
2097 stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
2098 expect(Ok, stat);
2099
2100 stat = GdipFillRectangle(graphics, brush, 0.0, 0.0, dpix, dpiy);
2101 expect(Ok, stat);
2102
2103 stat = GdipDeleteBrush(brush);
2104 expect(Ok, stat);
2105
2106 stat = GdipEndContainer(graphics, state1);
2107 expect(Ok, stat);
2108
2109 /* Restoring an invalid state seems to break the graphics object? */
2110 if (0) {
2111 stat = GdipEndContainer(graphics, state1);
2112 expect(Ok, stat);
2113 }
2114
2115 /* Ending metafile with a state open */
2116 stat = GdipBeginContainer2(graphics, &state1);
2117 expect(Ok, stat);
2118
2119 stat = GdipDeleteGraphics(graphics);
2120 expect(Ok, stat);
2121
2122 check_metafile(metafile, container_records, "container metafile", dst_points, &frame, UnitPixel);
2123
2124 sync_metafile(&metafile, "container.emf");
2125
2127 expect(Ok, stat);
2128
2130 expect(Ok, stat);
2131
2132 play_metafile(metafile, graphics, container_records, "container playback", dst_points, &frame, UnitPixel);
2133
2134 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
2135 expect(Ok, stat);
2136 expect(0, color);
2137
2138 stat = GdipBitmapGetPixel(bitmap, 12, 12, &color);
2139 expect(Ok, stat);
2140 expect(0xff000000, color);
2141
2143 expect(Ok, stat);
2144 expect(0xff0000ff, color);
2145
2146 stat = GdipBitmapGetPixel(bitmap, 42, 42, &color);
2147 expect(Ok, stat);
2148 expect(0xff00ff00, color);
2149
2150 stat = GdipBitmapGetPixel(bitmap, 55, 5, &color);
2151 expect(Ok, stat);
2152 expect(0xff00ffff, color);
2153
2154 stat = GdipDeleteGraphics(graphics);
2155 expect(Ok, stat);
2156
2158 expect(Ok, stat);
2159
2161 expect(Ok, stat);
2162}
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6621
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state)
Definition: graphics.c:5924
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6635
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, REAL sy, GpMatrixOrder order)
Definition: graphics.c:6051
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state)
Definition: graphics.c:6039
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state)
Definition: graphics.c:5917
UINT GraphicsContainer
Definition: gdiplusenums.h:23
@ MatrixOrderPrepend
Definition: gdiplusenums.h:188
@ UnitInch
Definition: gdiplusenums.h:31
static const emfplus_record container_records[]
Definition: metafile.c:1960
REAL Height
Definition: gdiplustypes.h:664
REAL X
Definition: gdiplustypes.h:661
REAL Width
Definition: gdiplustypes.h:663
REAL Y
Definition: gdiplustypes.h:662

Referenced by START_TEST().

◆ test_converttoemfplus()

static void test_converttoemfplus ( void  )
static

Definition at line 1816 of file metafile.c.

1817{
1818 GpStatus (WINAPI *pGdipConvertToEmfPlus)( const GpGraphics *graphics, GpMetafile *metafile, BOOL *succ,
1819 EmfType emfType, const WCHAR *description, GpMetafile **outmetafile);
1820 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1821 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1822 GpStatus stat;
1823 GpMetafile *metafile, *metafile2 = NULL, *emhmeta;
1824 GpGraphics *graphics;
1825 HDC hdc;
1826 BOOL succ;
1827 HMODULE mod = GetModuleHandleA("gdiplus.dll");
1828
1829 pGdipConvertToEmfPlus = (void*)GetProcAddress( mod, "GdipConvertToEmfPlus");
1830 if(!pGdipConvertToEmfPlus)
1831 {
1832 /* GdipConvertToEmfPlus was introduced in Windows Vista. */
1833 win_skip("GDIPlus version 1.1 not available\n");
1834 return;
1835 }
1836
1838
1840 expect(Ok, stat);
1841
1843 expect(Ok, stat);
1844
1845 DeleteDC(hdc);
1846
1847 if (stat != Ok)
1848 return;
1849
1851 expect(Ok, stat);
1852
1853 /* Invalid Parameters */
1854 stat = pGdipConvertToEmfPlus(NULL, metafile, &succ, EmfTypeEmfPlusOnly, description, &metafile2);
1856
1857 stat = pGdipConvertToEmfPlus(graphics, NULL, &succ, EmfTypeEmfPlusOnly, description, &metafile2);
1859
1860 stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, description, NULL);
1862
1863 stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, MetafileTypeInvalid, NULL, &metafile2);
1865
1866 stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, MetafileTypeEmfPlusDual+1, NULL, &metafile2);
1868
1869 /* If we are already an Enhanced Metafile then the conversion fails. */
1870 stat = pGdipConvertToEmfPlus(graphics, emhmeta, NULL, EmfTypeEmfPlusOnly, NULL, &metafile2);
1872
1873 stat = pGdipConvertToEmfPlus(graphics, metafile, NULL, EmfTypeEmfPlusOnly, NULL, &metafile2);
1875 if(metafile2)
1876 GdipDisposeImage((GpImage*)metafile2);
1877
1878 succ = FALSE;
1879 stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, NULL, &metafile2);
1881 if(metafile2)
1882 GdipDisposeImage((GpImage*)metafile2);
1883
1884 stat = GdipDeleteGraphics(graphics);
1885 expect(Ok, stat);
1886
1888 expect(Ok, stat);
1889
1890 stat = GdipDisposeImage((GpImage*)emhmeta);
1891 expect(Ok, stat);
1892}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
EmfType
Definition: gdiplusenums.h:233
@ MetafileTypeInvalid
Definition: gdiplusenums.h:216
@ MetafileTypeEmf
Definition: gdiplusenums.h:219
@ MetafileTypeEmfPlusDual
Definition: gdiplusenums.h:221
Status GpStatus
static int mod
Definition: i386-dis.c:1288
#define todo_wine
Definition: custom.c:79
#define win_skip
Definition: test.h:160
#define WINAPI
Definition: msvc.h:6

Referenced by START_TEST().

◆ test_drawimage()

static void test_drawimage ( void  )
static

Definition at line 2459 of file metafile.c.

2460{
2461 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
2462 static const GpPointF dst_points[3] = {{10.0,10.0},{85.0,15.0},{10.0,80.0}};
2463 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2464 const ColorMatrix double_red = {{
2465 {2.0,0.0,0.0,0.0,0.0},
2466 {0.0,1.0,0.0,0.0,0.0},
2467 {0.0,0.0,1.0,0.0,0.0},
2468 {0.0,0.0,0.0,1.0,0.0},
2469 {0.0,0.0,0.0,0.0,1.0}}};
2470
2471 GpImageAttributes *imageattr;
2473 GpGraphics *graphics;
2474 HENHMETAFILE hemf;
2475 GpStatus stat;
2477 BYTE buff[400];
2478 GpImage *image;
2479 HDC hdc;
2480
2483 expect(Ok, stat);
2484
2486 expect(Ok, stat);
2487
2488 memset(&info, 0, sizeof(info));
2489 info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2490 info.bmiHeader.biWidth = 10;
2491 info.bmiHeader.biHeight = 10;
2492 info.bmiHeader.biPlanes = 1;
2493 info.bmiHeader.biBitCount = 32;
2494 info.bmiHeader.biCompression = BI_RGB;
2495 memset(buff, 0x80, sizeof(buff));
2497 expect(Ok, stat);
2498
2499 stat = GdipCreateImageAttributes(&imageattr);
2500 expect(Ok, stat);
2501
2503 TRUE, &double_red, NULL, ColorMatrixFlagsDefault);
2504 expect(Ok, stat);
2505
2506 stat = GdipDrawImagePointsRect(graphics, image, dst_points, 3,
2507 0.0, 0.0, 10.0, 10.0, UnitPixel, imageattr, NULL, NULL);
2508 GdipDisposeImageAttributes(imageattr);
2509 expect(Ok, stat);
2510
2512
2513 stat = GdipDeleteGraphics(graphics);
2514 expect(Ok, stat);
2515 sync_metafile(&metafile, "draw_image_bitmap.emf");
2516
2518 expect(Ok, stat);
2519
2520 check_emfplus(hemf, draw_image_bitmap_records, "draw image bitmap");
2521
2522 /* test drawing metafile */
2524 expect(Ok, stat);
2525
2527 expect(Ok, stat);
2528
2530 expect(Ok, stat);
2531
2532 stat = GdipDrawImagePointsRect(graphics, image, dst_points, 3,
2533 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
2534 expect(Ok, stat);
2535
2537
2538 stat = GdipDeleteGraphics(graphics);
2539 expect(Ok, stat);
2540 sync_metafile(&metafile, "draw_image_metafile.emf");
2541
2543 expect(Ok, stat);
2544
2545 if (GetProcAddress(GetModuleHandleA("gdiplus.dll"), "GdipConvertToEmfPlus"))
2546 {
2547 check_emfplus(hemf, draw_image_metafile_records, "draw image metafile");
2548 }
2549 else
2550 {
2551 win_skip("draw image metafile records tests skipped\n");
2552 }
2553 DeleteEnhMetaFile(hemf);
2554
2555 DeleteDC(hdc);
2557 expect(Ok, stat);
2558}
GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO *info, VOID *bits, GpBitmap **bitmap)
Definition: image.c:1385
#define BI_RGB
Definition: precomp.h:56
static unsigned char buff[32768]
Definition: fatten.c:17
@ ColorAdjustTypeDefault
@ ColorMatrixFlagsDefault
GLeglImageOES image
Definition: gl.h:2204
GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix *colorMatrix, GDIPCONST ColorMatrix *grayMatrix, ColorMatrixFlags flags)
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
static const emfplus_record draw_image_metafile_records[]
Definition: metafile.c:2432
static const emfplus_record draw_image_bitmap_records[]
Definition: metafile.c:2417
#define memset(x, y, z)
Definition: compat.h:39
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_drawpath()

static void test_drawpath ( void  )
static

Definition at line 2652 of file metafile.c.

2653{
2654 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
2655 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2656
2658 GpGraphics *graphics;
2659 HENHMETAFILE hemf;
2660 GpStatus stat;
2661 GpPath *path;
2662 GpPen *pen;
2663 HDC hdc;
2664
2667 expect(Ok, stat);
2668 DeleteDC(hdc);
2669
2671 expect(Ok, stat);
2672
2674 expect(Ok, stat);
2675 stat = GdipAddPathLine(path, 5, 5, 30, 30);
2676 expect(Ok, stat);
2677
2678 stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
2679 expect(Ok, stat);
2680
2681 stat = GdipDrawPath(graphics, pen, path);
2682 expect(Ok, stat);
2683
2684 stat = GdipDeletePen(pen);
2685 expect(Ok, stat);
2687 expect(Ok, stat);
2688
2689 stat = GdipDeleteGraphics(graphics);
2690 expect(Ok, stat);
2691 sync_metafile(&metafile, "draw_path.emf");
2692
2694 expect(Ok, stat);
2695
2696 check_emfplus(hemf, draw_path_records, "draw path");
2697 DeleteEnhMetaFile(hemf);
2698
2700 expect(Ok, stat);
2701}
GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
Definition: graphics.c:4066
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphicspath.c:704
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen)
Definition: pen.c:136
GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
Definition: pen.c:192
@ FillModeAlternate
Definition: gdiplusenums.h:55
static const emfplus_record draw_path_records[]
Definition: metafile.c:2637

Referenced by START_TEST().

◆ test_emfonly()

static void test_emfonly ( void  )
static

Definition at line 728 of file metafile.c.

729{
732 GpImage *clone;
733 GpGraphics *graphics;
734 HDC hdc, metafile_dc;
735 GpRectF bounds;
736 GpUnit unit;
737 REAL xres, yres;
738 HENHMETAFILE hemf;
740 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
741 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
742 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
743 HBRUSH hbrush, holdbrush;
745 ARGB color;
746 GpPen *pen;
747
749
751 expect(Ok, stat);
752
753 DeleteDC(hdc);
754
755 if (stat != Ok)
756 return;
757
760
761 memset(&header, 0xaa, sizeof(header));
763 expect(Ok, stat);
765 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
766 /* The rest is zeroed or seemingly random/uninitialized garbage. */
767
769 expect(Ok, stat);
770
771 stat = GdipGetDC(graphics, &metafile_dc);
772 expect(Ok, stat);
773
774 if (stat != Ok)
775 {
776 GdipDeleteGraphics(graphics);
778 return;
779 }
780
781 hbrush = CreateSolidBrush(0xff0000);
782
783 holdbrush = SelectObject(metafile_dc, hbrush);
784
785 Rectangle(metafile_dc, 25, 25, 75, 75);
786
787 SelectObject(metafile_dc, holdbrush);
788
790
791 stat = GdipReleaseDC(graphics, metafile_dc);
792 expect(Ok, stat);
793
794 stat = GdipDeleteGraphics(graphics);
795 expect(Ok, stat);
796
797 check_metafile(metafile, emfonly_records, "emfonly metafile", dst_points, &frame, UnitPixel);
798
799 sync_metafile(&metafile, "emfonly.emf");
800
802 expect(Ok, stat);
803 expectf(0.0, bounds.X);
804 expectf(0.0, bounds.Y);
805 expectf_(100.0, bounds.Width, 0.05);
806 expectf_(100.0, bounds.Height, 0.05);
808
810 expect(Ok, stat);
811
813 expect(Ok, stat);
814
815 memset(&header, 0xaa, sizeof(header));
817 expect(Ok, stat);
819 expect(U(header).EmfHeader.nBytes, header.Size);
820 /* For some reason a recoreded EMF Metafile has an EMF+ version. */
821 todo_wine ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
822 expect(0, header.EmfPlusFlags);
823 expectf(xres, header.DpiX);
824 expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
825 expectf(yres, header.DpiY);
826 expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
827 expect(0, header.X);
828 expect(0, header.Y);
829 expect(100, header.Width);
830 expect(100, header.Height);
831 expect(0, header.EmfPlusHeaderSize);
832 expect(0, header.LogicalDpiX);
833 expect(0, header.LogicalDpiX);
834 expect(EMR_HEADER, U(header).EmfHeader.iType);
835 expect(25, U(header).EmfHeader.rclBounds.left);
836 expect(25, U(header).EmfHeader.rclBounds.top);
837 expect(74, U(header).EmfHeader.rclBounds.right);
838 expect(74, U(header).EmfHeader.rclBounds.bottom);
839 expect(0, U(header).EmfHeader.rclFrame.left);
840 expect(0, U(header).EmfHeader.rclFrame.top);
841 expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
842 expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
843
845 expect(Ok, stat);
846
848 expect(Ok, stat);
849
850 play_metafile(metafile, graphics, emfonly_records, "emfonly playback", dst_points, &frame, UnitPixel);
851
852 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
853 expect(Ok, stat);
854 expect(0, color);
855
856 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
857 expect(Ok, stat);
858 expect(0xff0000ff, color);
859
860 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
861 expect(Ok, stat);
862
863 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
864 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
865 expect(Ok, stat);
866
867 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
868 expect(Ok, stat);
869 expect(0, color);
870
871 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
872 expect(Ok, stat);
873 expect(0xff0000ff, color);
874
875 stat = GdipCloneImage((GpImage*)metafile, &clone);
876 expect(Ok, stat);
877
878 if (stat == Ok)
879 {
880 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
881 expect(Ok, stat);
882
883 stat = GdipDrawImagePointsRect(graphics, clone, dst_points, 3,
884 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
885 expect(Ok, stat);
886
887 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
888 expect(Ok, stat);
889 expect(0, color);
890
891 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
892 expect(Ok, stat);
893 expect(0xff0000ff, color);
894
895 GdipDisposeImage(clone);
896 }
897
898 stat = GdipDeleteGraphics(graphics);
899 expect(Ok, stat);
900
902 expect(Ok, stat);
903
905 expect(Ok, stat);
906
908 expect(Ok, stat);
909
910 check_emfplus(hemf, emfonly_records, "emfonly emf");
911
912 memset(&header, 0xaa, sizeof(header));
914 expect(Ok, stat);
916 expect(U(header).EmfHeader.nBytes, header.Size);
917 expect(0x10000, header.Version);
918 expect(0, header.EmfPlusFlags);
919 expectf(xres, header.DpiX);
920 expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
921 expectf(yres, header.DpiY);
922 expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
923 expect(0, header.X);
924 expect(0, header.Y);
925 expect(100, header.Width);
926 expect(100, header.Height);
927 expect(0, header.EmfPlusHeaderSize);
928 expect(0, header.LogicalDpiX);
929 expect(0, header.LogicalDpiX);
930 expect(EMR_HEADER, U(header).EmfHeader.iType);
931 expect(25, U(header).EmfHeader.rclBounds.left);
932 expect(25, U(header).EmfHeader.rclBounds.top);
933 expect(74, U(header).EmfHeader.rclBounds.right);
934 expect(74, U(header).EmfHeader.rclBounds.bottom);
935 expect(0, U(header).EmfHeader.rclFrame.left);
936 expect(0, U(header).EmfHeader.rclFrame.top);
937 expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
938 expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
939
941 expect(Ok, stat);
942
944 expect(Ok, stat);
945 expectf(0.0, bounds.X);
946 expectf(0.0, bounds.Y);
947 expectf_(100.0, bounds.Width, 0.05);
948 expectf_(100.0, bounds.Height, 0.05);
950
952 expect(Ok, stat);
953 expectf(header.DpiX, xres);
954
956 expect(Ok, stat);
957 expectf(header.DpiY, yres);
958
959 memset(&header, 0xaa, sizeof(header));
961 expect(Ok, stat);
963 expect(U(header).EmfHeader.nBytes, header.Size);
964 expect(0x10000, header.Version);
965 expect(0, header.EmfPlusFlags);
966 expectf(xres, header.DpiX);
967 expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
968 expectf(yres, header.DpiY);
969 expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
970 expect(0, header.X);
971 expect(0, header.Y);
972 expect(100, header.Width);
973 expect(100, header.Height);
974 expect(0, header.EmfPlusHeaderSize);
975 expect(0, header.LogicalDpiX);
976 expect(0, header.LogicalDpiX);
977 expect(EMR_HEADER, U(header).EmfHeader.iType);
978 expect(25, U(header).EmfHeader.rclBounds.left);
979 expect(25, U(header).EmfHeader.rclBounds.top);
980 expect(74, U(header).EmfHeader.rclBounds.right);
981 expect(74, U(header).EmfHeader.rclBounds.bottom);
982 expect(0, U(header).EmfHeader.rclFrame.left);
983 expect(0, U(header).EmfHeader.rclFrame.top);
984 expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
985 expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
986
988 expect(Ok, stat);
989
990 /* test drawing to metafile with gdi+ functions */
992
994 expect(Ok, stat);
995
996 DeleteDC(hdc);
997
998 if (stat != Ok)
999 return;
1000
1002 expect(Ok, stat);
1003
1004 stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1005 expect(Ok, stat);
1006 stat = GdipDrawLineI(graphics, pen, 0, 0, 10, 10);
1008 GdipDeletePen(pen);
1009
1010 stat = GdipDeleteGraphics(graphics);
1011 expect(Ok, stat);
1012
1013 check_metafile(metafile, emfonly_draw_records, "emfonly draw metafile", dst_points, &frame, UnitPixel);
1014 sync_metafile(&metafile, "emfonly_draw.emf");
1015
1017 expect(Ok, stat);
1018}
static HBRUSH hbrush
#define U(x)
Definition: wordpad.c:45
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
Definition: graphics.c:6682
GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2)
Definition: graphics.c:3589
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:6758
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
Definition: image.c:2378
GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap *bitmap, INT x, INT y, ARGB color)
Definition: image.c:494
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
Definition: image.c:2196
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2309
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromEmf(HENHMETAFILE hemf, MetafileHeader *header)
Definition: metafile.c:3688
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile *metafile, MetafileHeader *header)
Definition: metafile.c:3632
pKey DeleteObject()
@ EmfTypeEmfOnly
Definition: gdiplusenums.h:234
Unit
Definition: gdiplusenums.h:26
#define expectf_(expected, got, precision)
Definition: metafile.c:28
static const emfplus_record emfonly_records[]
Definition: metafile.c:697
#define expectf(expected, got)
Definition: metafile.c:29
static const emfplus_record emfonly_draw_records[]
Definition: metafile.c:708
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define EMR_HEADER
Definition: wingdi.h:75

Referenced by START_TEST().

◆ test_empty()

static void test_empty ( void  )
static

Definition at line 368 of file metafile.c.

369{
372 GpGraphics *graphics;
373 HDC hdc;
374 GpRectF bounds;
375 GpUnit unit;
376 REAL xres, yres;
377 HENHMETAFILE hemf, dummy;
379 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
380 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
381 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
382
384
387
390
393
396
399
402
404 expect(Ok, stat);
405
406 DeleteDC(hdc);
407
408 if (stat != Ok)
409 return;
410
413
415 expect(Ok, stat);
416
419
420 stat = GdipDeleteGraphics(graphics);
421 expect(Ok, stat);
422
423 check_metafile(metafile, empty_records, "empty metafile", dst_points, &frame, UnitPixel);
424
425 sync_metafile(&metafile, "empty.emf");
426
428 expect(Ok, stat);
429 expectf(0.0, bounds.X);
430 expectf(0.0, bounds.Y);
431 expectf_(100.0, bounds.Width, 0.05);
432 expectf_(100.0, bounds.Height, 0.05);
434
436 expect(Ok, stat);
437
439 expect(Ok, stat);
440
441 memset(&header, 0xaa, sizeof(header));
443 expect(Ok, stat);
445 expect(U(header).EmfHeader.nBytes, header.Size);
446 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
447 expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
448 expectf(xres, header.DpiX);
449 expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
450 expectf(yres, header.DpiY);
451 expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
452 expect(0, header.X);
453 expect(0, header.Y);
454 expect(100, header.Width);
455 expect(100, header.Height);
456 expect(28, header.EmfPlusHeaderSize);
457 expect(96, header.LogicalDpiX);
458 expect(96, header.LogicalDpiX);
459 expect(EMR_HEADER, U(header).EmfHeader.iType);
460 expect(0, U(header).EmfHeader.rclBounds.left);
461 expect(0, U(header).EmfHeader.rclBounds.top);
462 expect(-1, U(header).EmfHeader.rclBounds.right);
463 expect(-1, U(header).EmfHeader.rclBounds.bottom);
464 expect(0, U(header).EmfHeader.rclFrame.left);
465 expect(0, U(header).EmfHeader.rclFrame.top);
466 expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
467 expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
468
470 expect(Ok, stat);
471
474
476 expect(Ok, stat);
477
478 check_emfplus(hemf, empty_records, "empty emf");
479
480 memset(&header, 0xaa, sizeof(header));
482 expect(Ok, stat);
484 expect(U(header).EmfHeader.nBytes, header.Size);
485 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
486 expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
487 expectf(xres, header.DpiX);
488 expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
489 expectf(yres, header.DpiY);
490 expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
491 expect(0, header.X);
492 expect(0, header.Y);
493 expect(100, header.Width);
494 expect(100, header.Height);
495 expect(28, header.EmfPlusHeaderSize);
496 expect(96, header.LogicalDpiX);
497 expect(96, header.LogicalDpiX);
498 expect(EMR_HEADER, U(header).EmfHeader.iType);
499 expect(0, U(header).EmfHeader.rclBounds.left);
500 expect(0, U(header).EmfHeader.rclBounds.top);
501 expect(-1, U(header).EmfHeader.rclBounds.right);
502 expect(-1, U(header).EmfHeader.rclBounds.bottom);
503 expect(0, U(header).EmfHeader.rclFrame.left);
504 expect(0, U(header).EmfHeader.rclFrame.top);
505 expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
506 expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
507
509 expect(Ok, stat);
510
512 expect(Ok, stat);
513 expectf(0.0, bounds.X);
514 expectf(0.0, bounds.Y);
515 expectf_(100.0, bounds.Width, 0.05);
516 expectf_(100.0, bounds.Height, 0.05);
518
520 expect(Ok, stat);
521 expectf(header.DpiX, xres);
522
524 expect(Ok, stat);
525 expectf(header.DpiY, yres);
526
527 memset(&header, 0xaa, sizeof(header));
529 expect(Ok, stat);
531 expect(U(header).EmfHeader.nBytes, header.Size);
532 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
533 expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
534 expectf(xres, header.DpiX);
535 expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
536 expectf(yres, header.DpiY);
537 expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
538 expect(0, header.X);
539 expect(0, header.Y);
540 expect(100, header.Width);
541 expect(100, header.Height);
542 expect(28, header.EmfPlusHeaderSize);
543 expect(96, header.LogicalDpiX);
544 expect(96, header.LogicalDpiX);
545 expect(EMR_HEADER, U(header).EmfHeader.iType);
546 expect(0, U(header).EmfHeader.rclBounds.left);
547 expect(0, U(header).EmfHeader.rclBounds.top);
548 expect(-1, U(header).EmfHeader.rclBounds.right);
549 expect(-1, U(header).EmfHeader.rclBounds.bottom);
550 expect(0, U(header).EmfHeader.rclFrame.left);
551 expect(0, U(header).EmfHeader.rclFrame.top);
552 expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
553 expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
554
556 expect(Ok, stat);
557}
@ MetafileTypeEmfPlusOnly
Definition: gdiplusenums.h:220
@ MetafileTypeWmf
Definition: gdiplusenums.h:217
@ MetafileTypeWmfPlaceable
Definition: gdiplusenums.h:218
static const emfplus_record empty_records[]
Definition: metafile.c:360

Referenced by START_TEST().

◆ test_fillpath()

static void test_fillpath ( void  )
static

Definition at line 2717 of file metafile.c.

2718{
2719 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
2720 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2721 static const WCHAR winetestemfW[] = {'w','i','n','e','t','e','s','t','.','e','m','f',0};
2722
2724 GpGraphics *graphics;
2725 GpSolidFill *brush;
2726 HENHMETAFILE hemf;
2727 GpStatus stat;
2728 GpPath *path;
2729 HDC hdc;
2730
2733 expect(Ok, stat);
2734 DeleteDC(hdc);
2735
2737 expect(Ok, stat);
2738
2740 expect(Ok, stat);
2741 stat = GdipAddPathLine(path, 5, 5, 30, 30);
2742 expect(Ok, stat);
2743 stat = GdipAddPathLine(path, 30, 30, 5, 30);
2744 expect(Ok, stat);
2745
2746 stat = GdipCreateSolidFill(0xffaabbcc, &brush);
2747 expect(Ok, stat);
2748
2749 stat = GdipFillPath(graphics, (GpBrush*)brush, path);
2750 expect(Ok, stat);
2751
2752 stat = GdipDeleteBrush((GpBrush*)brush);
2753 expect(Ok, stat);
2755 expect(Ok, stat);
2756
2757 stat = GdipDeleteGraphics(graphics);
2758 expect(Ok, stat);
2759 sync_metafile(&metafile, "fill_path.emf");
2760
2762 expect(Ok, stat);
2763
2764 check_emfplus(hemf, fill_path_records, "fill path");
2765
2766 /* write to disk */
2767 DeleteEnhMetaFile(CopyEnhMetaFileW(hemf, winetestemfW));
2768
2769 DeleteEnhMetaFile(hemf);
2770
2772 expect(Ok, stat);
2773
2774 /* should succeed when given path to an EMF */
2776 expect(Ok, stat);
2777
2779 expect(Ok, stat);
2780
2781 DeleteFileW(winetestemfW);
2782
2785}
GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)
Definition: graphics.c:4391
GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR *file, GDIPCONST WmfPlaceableFileHeader *placeable, GpMetafile **metafile)
Definition: metafile.c:3896
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
@ GenericError
Definition: gdiplustypes.h:27
static const emfplus_record fill_path_records[]
Definition: metafile.c:2703
HENHMETAFILE WINAPI CopyEnhMetaFileW(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCWSTR pszFile)

Referenced by START_TEST().

◆ test_fillrect()

static void test_fillrect ( void  )
static

Definition at line 1029 of file metafile.c.

1030{
1031 GpStatus stat;
1033 GpGraphics *graphics;
1034 HDC hdc;
1035 HENHMETAFILE hemf;
1036 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
1037 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1038 static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
1039 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1041 ARGB color;
1042 GpBrush *brush;
1043
1045
1047 expect(Ok, stat);
1048
1049 DeleteDC(hdc);
1050
1051 if (stat != Ok)
1052 return;
1053
1056
1058 expect(Ok, stat);
1059
1060 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1061 expect(Ok, stat);
1062
1063 stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
1064 expect(Ok, stat);
1065
1066 stat = GdipDeleteBrush(brush);
1067 expect(Ok, stat);
1068
1069 stat = GdipDeleteGraphics(graphics);
1070 expect(Ok, stat);
1071
1072 check_metafile(metafile, fillrect_records, "fillrect metafile", dst_points, &frame, UnitPixel);
1073
1074 sync_metafile(&metafile, "fillrect.emf");
1075
1077 expect(Ok, stat);
1078
1080 expect(Ok, stat);
1081
1082 play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points, &frame, UnitPixel);
1083
1084 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1085 expect(Ok, stat);
1086 expect(0, color);
1087
1088 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1089 expect(Ok, stat);
1090 expect(0xff0000ff, color);
1091
1092 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
1093 expect(Ok, stat);
1094
1095 play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points_half, &frame, UnitPixel);
1096
1097 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1098 expect(Ok, stat);
1099 expect(0xff0000ff, color);
1100
1101 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1102 expect(Ok, stat);
1103 expect(0, color);
1104
1105 stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
1106 expect(Ok, stat);
1107
1108 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
1109 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
1110 expect(Ok, stat);
1111
1112 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
1113 expect(Ok, stat);
1114 expect(0, color);
1115
1116 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1117 expect(Ok, stat);
1118 expect(0xff0000ff, color);
1119
1120 stat = GdipDeleteGraphics(graphics);
1121 expect(Ok, stat);
1122
1124 expect(Ok, stat);
1125
1127 expect(Ok, stat);
1128}
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height)
Definition: graphics.c:4552
static const emfplus_record fillrect_records[]
Definition: metafile.c:1020

Referenced by START_TEST().

◆ test_frameunit()

static void test_frameunit ( void  )
static

Definition at line 1894 of file metafile.c.

1895{
1896 GpStatus stat;
1898 GpGraphics *graphics;
1899 HDC hdc;
1900 static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
1901 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1902 GpUnit unit;
1903 REAL dpix, dpiy;
1904 GpRectF bounds;
1905
1907
1909 expect(Ok, stat);
1910
1911 DeleteDC(hdc);
1912
1913 if (stat != Ok)
1914 return;
1915
1917 expect(Ok, stat);
1919 expectf(0.0, bounds.X);
1920 expectf(0.0, bounds.Y);
1921 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
1922 "expected 1.0, got %f\n", bounds.Width);
1923 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
1924 "expected 1.0, got %f\n", bounds.Height);
1925
1927 expect(Ok, stat);
1928
1930 expect(Ok, stat);
1932 expectf(0.0, bounds.X);
1933 expectf(0.0, bounds.Y);
1934 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
1935 "expected 1.0, got %f\n", bounds.Width);
1936 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
1937 "expected 1.0, got %f\n", bounds.Height);
1938
1939 stat = GdipDeleteGraphics(graphics);
1940 expect(Ok, stat);
1941
1943 expect(Ok, stat);
1944
1946 expect(Ok, stat);
1947
1949 expect(Ok, stat);
1951 expectf(0.0, bounds.X);
1952 expectf(0.0, bounds.Y);
1953 expectf_(5.0 * dpix, bounds.Width, 1.0);
1954 expectf_(5.0 * dpiy, bounds.Height, 1.0);
1955
1957 expect(Ok, stat);
1958}
@ MetafileFrameUnitInch
Definition: gdiplusenums.h:383

Referenced by START_TEST().

◆ test_gditransform()

static void test_gditransform ( void  )
static

Definition at line 2324 of file metafile.c.

2325{
2326 GpStatus stat;
2328 GpGraphics *graphics;
2329 HDC hdc, metafile_dc;
2330 HENHMETAFILE hemf;
2332 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2333 static const GpPointF dst_points[3] = {{0.0,0.0},{40.0,0.0},{0.0,40.0}};
2334 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
2335 HBRUSH hbrush, holdbrush;
2337 ARGB color;
2338
2340
2342 expect(Ok, stat);
2343
2344 DeleteDC(hdc);
2345
2346 if (stat != Ok)
2347 return;
2348
2351
2352 memset(&header, 0xaa, sizeof(header));
2354 expect(Ok, stat);
2356 ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
2357
2359 expect(Ok, stat);
2360
2361 stat = GdipGetDC(graphics, &metafile_dc);
2362 expect(Ok, stat);
2363
2364 if (stat != Ok)
2365 {
2366 GdipDeleteGraphics(graphics);
2368 return;
2369 }
2370
2371 hbrush = CreateSolidBrush(0xff);
2372
2373 holdbrush = SelectObject(metafile_dc, hbrush);
2374
2375 GdiComment(metafile_dc, 8, (const BYTE*)"winetest");
2376
2377 SelectObject(metafile_dc, holdbrush);
2378
2380
2381 stat = GdipReleaseDC(graphics, metafile_dc);
2382 expect(Ok, stat);
2383
2384 stat = GdipDeleteGraphics(graphics);
2385 expect(Ok, stat);
2386
2387 check_metafile(metafile, gditransform_records, "gditransform metafile", dst_points, &frame, UnitPixel);
2388
2389 sync_metafile(&metafile, "gditransform.emf");
2390
2392 expect(Ok, stat);
2393
2395 expect(Ok, stat);
2396
2397 play_metafile(metafile, graphics, gditransform_records, "gditransform playback", dst_points, &frame, UnitPixel);
2398
2399 stat = GdipBitmapGetPixel(bitmap, 10, 10, &color);
2400 expect(Ok, stat);
2401 expect(0xffff0000, color);
2402
2403 stat = GdipBitmapGetPixel(bitmap, 30, 30, &color);
2404 expect(Ok, stat);
2405 expect(0x00000000, color);
2406
2407 stat = GdipDeleteGraphics(graphics);
2408 expect(Ok, stat);
2409
2411 expect(Ok, stat);
2412
2414 expect(Ok, stat);
2415}
static const emfplus_record gditransform_records[]
Definition: metafile.c:2313
BOOL WINAPI GdiComment(_In_ HDC hdc, _In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpData)

Referenced by START_TEST().

◆ test_gditransform_cb()

static void test_gditransform_cb ( GpMetafile metafile,
EmfPlusRecordType  record_type,
unsigned int  flags,
unsigned int  dataSize,
const unsigned char pStr 
)
static

Definition at line 2299 of file metafile.c.

2301{
2302 static const XFORM xform = {0.5, 0, 0, 0.5, 0, 0};
2303 static const RECTL rectangle = {0,0,100,100};
2304 GpStatus stat;
2305
2306 stat = GdipPlayMetafileRecord(metafile, EMR_SETWORLDTRANSFORM, 0, sizeof(xform), (void*)&xform);
2307 expect(Ok, stat);
2308
2309 stat = GdipPlayMetafileRecord(metafile, EMR_RECTANGLE, 0, sizeof(rectangle), (void*)&rectangle);
2310 expect(Ok, stat);
2311}
#define EMR_RECTANGLE
Definition: wingdi.h:117
#define EMR_SETWORLDTRANSFORM
Definition: wingdi.h:109

◆ test_getdc()

static void test_getdc ( void  )
static

Definition at line 573 of file metafile.c.

574{
577 GpGraphics *graphics;
578 HDC hdc, metafile_dc;
579 HENHMETAFILE hemf;
580 BOOL ret;
581 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
582 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
583 static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
584 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
585 HBRUSH hbrush, holdbrush;
587 ARGB color;
588
590
592 expect(Ok, stat);
593
594 DeleteDC(hdc);
595
596 if (stat != Ok)
597 return;
598
601
603 expect(Ok, stat);
604
605 stat = GdipGetDC(graphics, &metafile_dc);
606 expect(Ok, stat);
607
608 if (stat != Ok)
609 {
610 GdipDeleteGraphics(graphics);
612 return;
613 }
614
615 hbrush = CreateSolidBrush(0xff0000);
616
617 holdbrush = SelectObject(metafile_dc, hbrush);
618
619 Rectangle(metafile_dc, 25, 25, 75, 75);
620
621 SelectObject(metafile_dc, holdbrush);
622
624
625 stat = GdipReleaseDC(graphics, metafile_dc);
626 expect(Ok, stat);
627
628 stat = GdipDeleteGraphics(graphics);
629 expect(Ok, stat);
630
631 check_metafile(metafile, getdc_records, "getdc metafile", dst_points, &frame, UnitPixel);
632
633 sync_metafile(&metafile, "getdc.emf");
634
636 expect(Ok, stat);
637
639 expect(Ok, stat);
640
641 play_metafile(metafile, graphics, getdc_records, "getdc playback", dst_points, &frame, UnitPixel);
642
643 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
644 expect(Ok, stat);
645 expect(0, color);
646
647 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
648 expect(Ok, stat);
649 expect(0xff0000ff, color);
650
651 stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
652 expect(Ok, stat);
653
654 play_metafile(metafile, graphics, getdc_records, "getdc playback", dst_points_half, &frame, UnitPixel);
655
656 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
657 expect(Ok, stat);
658 expect(0xff0000ff, color);
659
660 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
661 expect(Ok, stat);
662 expect(0, color);
663
664 stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
665 expect(Ok, stat);
666
667 stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
668 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
669 expect(Ok, stat);
670
671 stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
672 expect(Ok, stat);
673 expect(0, color);
674
675 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
676 expect(Ok, stat);
677 expect(0xff0000ff, color);
678
679 stat = GdipDeleteGraphics(graphics);
680 expect(Ok, stat);
681
683 expect(Ok, stat);
684
686 expect(Ok, stat);
687
689 expect(Ok, stat);
690
691 check_emfplus(hemf, getdc_records, "getdc emf");
692
693 ret = DeleteEnhMetaFile(hemf);
694 ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
695}
static const emfplus_record getdc_records[]
Definition: metafile.c:559
int ret

Referenced by START_TEST().

◆ test_nullframerect()

static void test_nullframerect ( void  )
static

Definition at line 1219 of file metafile.c.

1219 {
1220 GpStatus stat;
1222 GpGraphics *graphics;
1223 HDC hdc, metafile_dc;
1224 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1225 GpBrush *brush;
1226 HBRUSH hbrush, holdbrush;
1227 GpRectF bounds;
1228 GpUnit unit;
1229
1231
1233 expect(Ok, stat);
1234
1235 DeleteDC(hdc);
1236
1237 if (stat != Ok)
1238 return;
1239
1241 expect(Ok, stat);
1243 expectf(0.0, bounds.X);
1244 expectf(0.0, bounds.Y);
1245 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
1246 "expected 1.0, got %f\n", bounds.Width);
1247 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
1248 "expected 1.0, got %f\n", bounds.Height);
1249
1251 expect(Ok, stat);
1252
1253 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1254 expect(Ok, stat);
1255
1256 stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
1257 expect(Ok, stat);
1258
1259 stat = GdipDeleteBrush(brush);
1260 expect(Ok, stat);
1261
1263 expect(Ok, stat);
1265 expectf(0.0, bounds.X);
1266 expectf(0.0, bounds.Y);
1267 ok(bounds.Width == 1.0 || broken(bounds.Width == 0.0) /* xp sp1 */,
1268 "expected 1.0, got %f\n", bounds.Width);
1269 ok(bounds.Height == 1.0 || broken(bounds.Height == 0.0) /* xp sp1 */,
1270 "expected 1.0, got %f\n", bounds.Height);
1271
1272 stat = GdipDeleteGraphics(graphics);
1273 expect(Ok, stat);
1274
1276 expect(Ok, stat);
1278 expectf_(25.0, bounds.X, 0.05);
1279 expectf_(25.0, bounds.Y, 0.05);
1280 expectf_(75.0, bounds.Width, 0.05);
1281 expectf_(75.0, bounds.Height, 0.05);
1282
1284 expect(Ok, stat);
1285
1287
1289 expect(Ok, stat);
1290
1291 DeleteDC(hdc);
1292
1294 expect(Ok, stat);
1295
1296 stat = GdipGetDC(graphics, &metafile_dc);
1297 expect(Ok, stat);
1298
1299 if (stat != Ok)
1300 {
1301 GdipDeleteGraphics(graphics);
1303 return;
1304 }
1305
1306 hbrush = CreateSolidBrush(0xff0000);
1307
1308 holdbrush = SelectObject(metafile_dc, hbrush);
1309
1310 Rectangle(metafile_dc, 25, 25, 75, 75);
1311
1312 SelectObject(metafile_dc, holdbrush);
1313
1315
1316 stat = GdipReleaseDC(graphics, metafile_dc);
1317 expect(Ok, stat);
1318
1319 stat = GdipDeleteGraphics(graphics);
1320 expect(Ok, stat);
1321
1323 expect(Ok, stat);
1325 expectf_(25.0, bounds.X, 0.05);
1326 expectf_(25.0, bounds.Y, 0.05);
1327 todo_wine expectf_(50.0, bounds.Width, 0.05);
1328 todo_wine expectf_(50.0, bounds.Height, 0.05);
1329
1331 expect(Ok, stat);
1332}
@ MetafileFrameUnitMillimeter
Definition: gdiplusenums.h:385

Referenced by START_TEST().

◆ test_pagetransform()

static void test_pagetransform ( void  )
static

Definition at line 1351 of file metafile.c.

1352{
1353 GpStatus stat;
1355 GpGraphics *graphics;
1356 HDC hdc;
1357 static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
1358 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1359 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1361 ARGB color;
1362 GpBrush *brush;
1363 GpUnit unit;
1364 REAL scale, dpix, dpiy;
1365 UINT width, height;
1366
1368
1370 expect(Ok, stat);
1371
1372 DeleteDC(hdc);
1373
1374 if (stat != Ok)
1375 return;
1376
1379
1382
1385
1388
1390 expect(Ok, stat);
1391
1392 /* initial scale */
1393 stat = GdipGetPageUnit(graphics, &unit);
1394 expect(Ok, stat);
1396
1397 stat = GdipGetPageScale(graphics, &scale);
1398 expect(Ok, stat);
1399 expectf(1.0, scale);
1400
1401 stat = GdipGetDpiX(graphics, &dpix);
1402 expect(Ok, stat);
1403 expectf(96.0, dpix);
1404
1405 stat = GdipGetDpiY(graphics, &dpiy);
1406 expect(Ok, stat);
1407 expectf(96.0, dpiy);
1408
1409 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1410 expect(Ok, stat);
1411
1412 stat = GdipFillRectangleI(graphics, brush, 1, 2, 1, 1);
1413 expect(Ok, stat);
1414
1415 stat = GdipDeleteBrush(brush);
1416 expect(Ok, stat);
1417
1418 /* page unit = pixels */
1419 stat = GdipSetPageUnit(graphics, UnitPixel);
1420 expect(Ok, stat);
1421
1422 stat = GdipGetPageUnit(graphics, &unit);
1423 expect(Ok, stat);
1425
1426 stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
1427 expect(Ok, stat);
1428
1429 stat = GdipFillRectangleI(graphics, brush, 0, 1, 1, 1);
1430 expect(Ok, stat);
1431
1432 stat = GdipDeleteBrush(brush);
1433 expect(Ok, stat);
1434
1435 /* page scale = 3, unit = pixels */
1436 stat = GdipSetPageScale(graphics, 3.0);
1437 expect(Ok, stat);
1438
1439 stat = GdipGetPageScale(graphics, &scale);
1440 expect(Ok, stat);
1441 expectf(3.0, scale);
1442
1443 stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
1444 expect(Ok, stat);
1445
1446 stat = GdipFillRectangleI(graphics, brush, 0, 1, 2, 2);
1447 expect(Ok, stat);
1448
1449 stat = GdipDeleteBrush(brush);
1450 expect(Ok, stat);
1451
1452 /* page scale = 3, unit = inches */
1453 stat = GdipSetPageUnit(graphics, UnitInch);
1454 expect(Ok, stat);
1455
1456 stat = GdipGetPageUnit(graphics, &unit);
1457 expect(Ok, stat);
1459
1460 stat = GdipCreateSolidFill((ARGB)0xffff0000, (GpSolidFill**)&brush);
1461 expect(Ok, stat);
1462
1463 stat = GdipFillRectangle(graphics, brush, 1.0/96.0, 0, 1, 1);
1464 expect(Ok, stat);
1465
1466 stat = GdipDeleteBrush(brush);
1467 expect(Ok, stat);
1468
1469 /* page scale = 3, unit = display */
1470 stat = GdipSetPageUnit(graphics, UnitDisplay);
1471 expect(Ok, stat);
1472
1473 stat = GdipGetPageUnit(graphics, &unit);
1474 expect(Ok, stat);
1476
1477 stat = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
1478 expect(Ok, stat);
1479
1480 stat = GdipFillRectangle(graphics, brush, 3, 3, 2, 2);
1481 expect(Ok, stat);
1482
1483 stat = GdipDeleteBrush(brush);
1484 expect(Ok, stat);
1485
1486 stat = GdipDeleteGraphics(graphics);
1487 expect(Ok, stat);
1488
1489 check_metafile(metafile, pagetransform_records, "pagetransform metafile", dst_points, &frame, UnitPixel);
1490
1491 sync_metafile(&metafile, "pagetransform.emf");
1492
1494 expect(Ok, stat);
1495
1497 expect(Ok, stat);
1498
1499 play_metafile(metafile, graphics, pagetransform_records, "pagetransform playback", dst_points, &frame, UnitPixel);
1500
1501 stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
1502 expect(Ok, stat);
1503 expect(0, color);
1504
1505 stat = GdipBitmapGetPixel(bitmap, 30, 50, &color);
1506 expect(Ok, stat);
1507 expect(0xff0000ff, color);
1508
1509 stat = GdipBitmapGetPixel(bitmap, 10, 30, &color);
1510 expect(Ok, stat);
1511 expect(0xff00ff00, color);
1512
1513 stat = GdipBitmapGetPixel(bitmap, 20, 80, &color);
1514 expect(Ok, stat);
1515 expect(0xff00ffff, color);
1516
1517 stat = GdipBitmapGetPixel(bitmap, 80, 20, &color);
1518 expect(Ok, stat);
1519 expect(0xffff0000, color);
1520
1521 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
1522 expect(Ok, stat);
1523 expect(0xffff00ff, color);
1524
1525 stat = GdipDeleteGraphics(graphics);
1526 expect(Ok, stat);
1527
1529 expect(Ok, stat);
1530
1532 expect(Ok, stat);
1533}
GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale)
Definition: graphics.c:4912
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
Definition: graphics.c:6202
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics *graphics, GpUnit *unit)
Definition: graphics.c:4927
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
Definition: graphics.c:6178
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2390
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2287
@ UnitDisplay
Definition: gdiplusenums.h:28
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
static const emfplus_record pagetransform_records[]
Definition: metafile.c:1334
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_properties()

static void test_properties ( void  )
static

Definition at line 2574 of file metafile.c.

2575{
2576 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
2577 static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
2578
2580 GpGraphics *graphics;
2581 HENHMETAFILE hemf;
2582 GpStatus stat;
2583 HDC hdc;
2584
2587 expect(Ok, stat);
2588 DeleteDC(hdc);
2589
2591 expect(Ok, stat);
2592
2594 expect(Ok, stat);
2596 expect(Ok, stat);
2597
2599 expect(Ok, stat);
2601 expect(Ok, stat);
2602
2604 expect(Ok, stat);
2606 expect(Ok, stat);
2607
2609 expect(Ok, stat);
2611 expect(Ok, stat);
2612
2614 expect(Ok, stat);
2616 expect(Ok, stat);
2617
2619 expect(Ok, stat);
2621 expect(Ok, stat);
2622
2623 stat = GdipDeleteGraphics(graphics);
2624 expect(Ok, stat);
2625 sync_metafile(&metafile, "properties.emf");
2626
2628 expect(Ok, stat);
2629
2630 check_emfplus(hemf, properties_records, "properties");
2631 DeleteEnhMetaFile(hemf);
2632
2634 expect(Ok, stat);
2635}
GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics, CompositingMode mode)
Definition: graphics.c:6085
GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics, TextRenderingHint hint)
Definition: graphics.c:6330
GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics, CompositingQuality quality)
Definition: graphics.c:6114
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, InterpolationMode mode)
Definition: graphics.c:6143
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
Definition: graphics.c:6289
GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode mode)
Definition: graphics.c:6229
@ SmoothingModeAntiAlias
Definition: gdiplusenums.h:127
@ CompositingModeSourceOver
Definition: gdiplusenums.h:249
@ CompositingModeSourceCopy
Definition: gdiplusenums.h:250
@ PixelOffsetModeHighQuality
Definition: gdiplusenums.h:164
@ CompositingQualityHighQuality
Definition: gdiplusenums.h:135
@ TextRenderingHintAntiAlias
Definition: gdiplusenums.h:259
@ TextRenderingHintSystemDefault
Definition: gdiplusenums.h:255
@ InterpolationModeHighQuality
Definition: gdiplusenums.h:145
@ InterpolationModeDefault
Definition: gdiplusenums.h:143
static const emfplus_record properties_records[]
Definition: metafile.c:2560

Referenced by START_TEST().

◆ test_worldtransform()

static void test_worldtransform ( void  )
static

Definition at line 1556 of file metafile.c.

1557{
1558 GpStatus stat;
1560 GpGraphics *graphics;
1561 HDC hdc;
1562 static const GpRectF frame = {0.0, 0.0, 5.0, 5.0};
1563 static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
1564 static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
1566 ARGB color;
1567 GpBrush *brush;
1569 BOOL identity;
1570 REAL elements[6];
1571
1573
1575 expect(Ok, stat);
1576
1577 DeleteDC(hdc);
1578
1579 if (stat != Ok)
1580 return;
1581
1583 expect(Ok, stat);
1584
1586 expect(Ok, stat);
1587
1588 /* initial transform */
1590 expect(Ok, stat);
1591
1593 expect(Ok, stat);
1595
1596 stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
1597 expect(Ok, stat);
1598
1599 stat = GdipFillRectangleI(graphics, brush, 0, 0, 1, 1);
1600 expect(Ok, stat);
1601
1602 stat = GdipDeleteBrush(brush);
1603 expect(Ok, stat);
1604
1605 /* scale transform */
1606 stat = GdipScaleWorldTransform(graphics, 2.0, 4.0, MatrixOrderPrepend);
1607 expect(Ok, stat);
1608
1610 expect(Ok, stat);
1611
1613 expect(Ok, stat);
1614 expectf(2.0, elements[0]);
1615 expectf(0.0, elements[1]);
1616 expectf(0.0, elements[2]);
1617 expectf(4.0, elements[3]);
1618 expectf(0.0, elements[4]);
1619 expectf(0.0, elements[5]);
1620
1621 stat = GdipCreateSolidFill((ARGB)0xff00ff00, (GpSolidFill**)&brush);
1622 expect(Ok, stat);
1623
1624 stat = GdipFillRectangle(graphics, brush, 0.5, 0.5, 0.5, 0.25);
1625 expect(Ok, stat);
1626
1627 stat = GdipDeleteBrush(brush);
1628 expect(Ok, stat);
1629
1630 /* reset transform */
1631 stat = GdipResetWorldTransform(graphics);
1632 expect(Ok, stat);
1633
1635 expect(Ok, stat);
1636
1638 expect(Ok, stat);
1640
1641 stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush);
1642 expect(Ok, stat);
1643
1644 stat = GdipFillRectangle(graphics, brush, 1.0, 0.0, 1.0, 1.0);
1645 expect(Ok, stat);
1646
1647 stat = GdipDeleteBrush(brush);
1648 expect(Ok, stat);
1649
1650 /* multiply transform */
1651 stat = GdipSetMatrixElements(transform, 2.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1652 expect(Ok, stat);
1653
1655 expect(Ok, stat);
1656
1658 expect(Ok, stat);
1659
1661 expect(Ok, stat);
1662 expectf(2.0, elements[0]);
1663 expectf(0.0, elements[1]);
1664 expectf(0.0, elements[2]);
1665 expectf(1.0, elements[3]);
1666 expectf(0.0, elements[4]);
1667 expectf(0.0, elements[5]);
1668
1669 stat = GdipCreateSolidFill((ARGB)0xffff0000, (GpSolidFill**)&brush);
1670 expect(Ok, stat);
1671
1672 stat = GdipFillRectangle(graphics, brush, 1.0, 1.0, 0.5, 1.0);
1673 expect(Ok, stat);
1674
1675 stat = GdipDeleteBrush(brush);
1676 expect(Ok, stat);
1677
1678 /* rotate transform */
1680 expect(Ok, stat);
1681
1683 expect(Ok, stat);
1684
1686 expect(Ok, stat);
1687 expectf(0.0, elements[0]);
1688 expectf(2.0, elements[1]);
1689 expectf(-1.0, elements[2]);
1690 expectf(0.0, elements[3]);
1691 expectf(0.0, elements[4]);
1692 expectf(0.0, elements[5]);
1693
1694 stat = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
1695 expect(Ok, stat);
1696
1697 stat = GdipFillRectangle(graphics, brush, 1.0, -1.0, 0.5, 1.0);
1698 expect(Ok, stat);
1699
1700 stat = GdipDeleteBrush(brush);
1701 expect(Ok, stat);
1702
1703 /* set transform */
1704 stat = GdipSetMatrixElements(transform, 1.0, 0.0, 0.0, 3.0, 0.0, 0.0);
1705 expect(Ok, stat);
1706
1708 expect(Ok, stat);
1709
1711 expect(Ok, stat);
1712
1714 expect(Ok, stat);
1715 expectf(1.0, elements[0]);
1716 expectf(0.0, elements[1]);
1717 expectf(0.0, elements[2]);
1718 expectf(3.0, elements[3]);
1719 expectf(0.0, elements[4]);
1720 expectf(0.0, elements[5]);
1721
1722 stat = GdipCreateSolidFill((ARGB)0xffffff00, (GpSolidFill**)&brush);
1723 expect(Ok, stat);
1724
1725 stat = GdipFillRectangle(graphics, brush, 1.0, 1.0, 1.0, 1.0);
1726 expect(Ok, stat);
1727
1728 stat = GdipDeleteBrush(brush);
1729 expect(Ok, stat);
1730
1731 /* translate transform */
1732 stat = GdipTranslateWorldTransform(graphics, -1.0, 0.0, MatrixOrderAppend);
1733 expect(Ok, stat);
1734
1736 expect(Ok, stat);
1737
1739 expect(Ok, stat);
1740 expectf(1.0, elements[0]);
1741 expectf(0.0, elements[1]);
1742 expectf(0.0, elements[2]);
1743 expectf(3.0, elements[3]);
1744 expectf(-1.0, elements[4]);
1745 expectf(0.0, elements[5]);
1746
1747 stat = GdipCreateSolidFill((ARGB)0xffffffff, (GpSolidFill**)&brush);
1748 expect(Ok, stat);
1749
1750 stat = GdipFillRectangle(graphics, brush, 1.0, 1.0, 1.0, 1.0);
1751 expect(Ok, stat);
1752
1753 stat = GdipDeleteBrush(brush);
1754 expect(Ok, stat);
1755
1757 expect(Ok, stat);
1758
1759 stat = GdipDeleteGraphics(graphics);
1760 expect(Ok, stat);
1761
1762 check_metafile(metafile, worldtransform_records, "worldtransform metafile", dst_points, &frame, UnitPixel);
1763
1764 sync_metafile(&metafile, "worldtransform.emf");
1765
1767 expect(Ok, stat);
1768
1770 expect(Ok, stat);
1771
1772 play_metafile(metafile, graphics, worldtransform_records, "worldtransform playback", dst_points, &frame, UnitPixel);
1773
1774 stat = GdipBitmapGetPixel(bitmap, 80, 80, &color);
1775 expect(Ok, stat);
1776 expect(0, color);
1777
1778 stat = GdipBitmapGetPixel(bitmap, 10, 10, &color);
1779 expect(Ok, stat);
1780 expect(0xff0000ff, color);
1781
1782 stat = GdipBitmapGetPixel(bitmap, 30, 50, &color);
1783 expect(Ok, stat);
1784 expect(0xff00ff00, color);
1785
1786 stat = GdipBitmapGetPixel(bitmap, 30, 10, &color);
1787 expect(Ok, stat);
1788 expect(0xff00ffff, color);
1789
1790 stat = GdipBitmapGetPixel(bitmap, 50, 30, &color);
1791 expect(Ok, stat);
1792 expect(0xffff0000, color);
1793
1794 stat = GdipBitmapGetPixel(bitmap, 10, 50, &color);
1795 expect(Ok, stat);
1796 expect(0xffff00ff, color);
1797
1798 stat = GdipBitmapGetPixel(bitmap, 30, 90, &color);
1799 expect(Ok, stat);
1800 expect(0xffffff00, color);
1801
1802 stat = GdipBitmapGetPixel(bitmap, 10, 90, &color);
1803 expect(Ok, stat);
1804 expect(0xffffffff, color);
1805
1806 stat = GdipDeleteGraphics(graphics);
1807 expect(Ok, stat);
1808
1810 expect(Ok, stat);
1811
1813 expect(Ok, stat);
1814}
GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle, GpMatrixOrder order)
Definition: graphics.c:5862
GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx, REAL dy, GpMatrixOrder order)
Definition: graphics.c:6386
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:6358
GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
Definition: graphics.c:6649
GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:5062
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
Definition: graphics.c:5840
GpStatus WINGDIPAPI GdipGetMatrixElements(GDIPCONST GpMatrix *matrix, REAL *out)
Definition: matrix.c:172
GpStatus WINGDIPAPI GdipSetMatrixElements(GpMatrix *matrix, REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
Definition: matrix.c:316
GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix *matrix, BOOL *result)
Definition: matrix.c:512
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:160
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:140
@ MatrixOrderAppend
Definition: gdiplusenums.h:189
GLuint GLenum GLenum transform
Definition: glext.h:9407
static const emfplus_record worldtransform_records[]
Definition: metafile.c:1535

Referenced by START_TEST().

Variable Documentation

◆ clear_emf_records

const emfplus_record clear_emf_records[]
static
Initial value:
= {
{ EMR_SAVEDC, 0, 1 },
{ EMR_SETICMMODE, 0, 1 },
{ EMR_BITBLT, 0, 1 },
{ EMR_RESTOREDC, 0, 1 },
{ EMR_EOF },
{ 0 }
}
@ EmfPlusRecordTypeClear
Definition: gdiplusenums.h:668
@ EmfPlusRecordTypeHeader
Definition: gdiplusenums.h:660
@ EmfPlusRecordTypeEndOfFile
Definition: gdiplusenums.h:661
#define EMR_SAVEDC
Definition: wingdi.h:107
#define EMR_BITBLT
Definition: wingdi.h:149
#define EMR_RESTOREDC
Definition: wingdi.h:108
#define EMR_EOF
Definition: wingdi.h:88
#define EMR_SETICMMODE
Definition: wingdi.h:171

Definition at line 1130 of file metafile.c.

Referenced by test_clear().

◆ clipping_records

const emfplus_record clipping_records[]
static
Initial value:

Definition at line 2164 of file metafile.c.

Referenced by test_clipping().

◆ container_records

◆ draw_image_bitmap_records

const emfplus_record draw_image_bitmap_records[]
static
Initial value:

Definition at line 2417 of file metafile.c.

Referenced by test_drawimage().

◆ draw_image_metafile_records

const emfplus_record draw_image_metafile_records[]
static

◆ draw_path_records

const emfplus_record draw_path_records[]
static
Initial value:

Definition at line 2637 of file metafile.c.

Referenced by test_drawpath().

◆ emfonly_draw_records

const emfplus_record emfonly_draw_records[]
static
Initial value:
= {
{ EMR_SAVEDC, 0, 1 },
{ EMR_SETICMMODE, 0, 1 },
{ EMR_SETMITERLIMIT, 0, 1 },
{ EMR_EXTCREATEPEN, 0, 1 },
{ EMR_SELECTOBJECT, 0, 1 },
{ EMR_SELECTOBJECT, 0, 1 },
{ EMR_POLYLINE16, 0, 1 },
{ EMR_SELECTOBJECT, 0, 1 },
{ EMR_SELECTOBJECT, 0, 1 },
{ EMR_DELETEOBJECT, 0, 1 },
{ EMR_SETMITERLIMIT, 0, 1 },
{ EMR_RESTOREDC, 0, 1 },
{ EMR_EOF },
{ 0, 0, 1 }
}
#define EMR_SELECTOBJECT
Definition: wingdi.h:111
#define EMR_SETMITERLIMIT
Definition: wingdi.h:132
#define EMR_POLYLINE16
Definition: wingdi.h:160
#define EMR_EXTCREATEPEN
Definition: wingdi.h:168
#define EMR_DELETEOBJECT
Definition: wingdi.h:114
#define EMR_MODIFYWORLDTRANSFORM
Definition: wingdi.h:110

Definition at line 708 of file metafile.c.

Referenced by test_emfonly().

◆ emfonly_records

const emfplus_record emfonly_records[]
static
Initial value:
= {
{ EMR_EOF },
{ 0 }
}
#define EMR_CREATEBRUSHINDIRECT
Definition: wingdi.h:113

Definition at line 697 of file metafile.c.

Referenced by test_emfonly().

◆ empty_records

const emfplus_record empty_records[]
static
Initial value:

Definition at line 360 of file metafile.c.

Referenced by test_empty().

◆ fill_path_records

const emfplus_record fill_path_records[]
static
Initial value:
= {
{ EMR_SAVEDC, 0, 1 },
{ EMR_SETICMMODE, 0, 1 },
{ EMR_BITBLT, 0, 1 },
{ EMR_RESTOREDC, 0, 1 },
{ EMR_EOF },
{ 0 }
}
@ EmfPlusRecordTypeFillPath
Definition: gdiplusenums.h:679

Definition at line 2703 of file metafile.c.

Referenced by test_fillpath().

◆ fillrect_records

const emfplus_record fillrect_records[]
static
Initial value:

Definition at line 1020 of file metafile.c.

Referenced by test_fillrect().

◆ gditransform_records

const emfplus_record gditransform_records[]
static
Initial value:
= {
{ EMR_EOF },
{ 0 }
}
static void test_gditransform_cb(GpMetafile *metafile, EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr)
Definition: metafile.c:2299

Definition at line 2313 of file metafile.c.

Referenced by test_gditransform().

◆ getdc_records

const emfplus_record getdc_records[]
static
Initial value:

Definition at line 559 of file metafile.c.

Referenced by test_getdc().

◆ load_metafiles

BOOL load_metafiles
static

Definition at line 32 of file metafile.c.

Referenced by START_TEST(), and sync_metafile().

◆ pagetransform_records

◆ properties_records

◆ save_metafiles

BOOL save_metafiles
static

Definition at line 31 of file metafile.c.

Referenced by START_TEST(), and sync_metafile().

◆ worldtransform_records

const emfplus_record worldtransform_records[]
static