ReactOS  0.4.14-dev-52-g6116262
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.

◆ ObjectType

Enumerator
ObjectTypeInvalid 
ObjectTypeBrush 
ObjectTypePen 
ObjectTypePath 
ObjectTypeRegion 
ObjectTypeImage 
ObjectTypeFont 
ObjectTypeStringFormat 
ObjectTypeImageAttributes 
ObjectTypeCustomLineCap 

Definition at line 80 of file metafile.c.

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 CALLBACK enum_emf_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
Definition: metafile.c:113
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI EnumEnhMetaFile(_In_opt_ HDC, _In_ HENHMETAFILE, _In_ ENHMFENUMPROC, _In_opt_ PVOID, _In_opt_ LPCRECT)
#define todo_wine_if(is_todo)
Definition: test.h:155
static int state
Definition: maze.c:121
#define ok(value,...)
Definition: atltest.h:57
BOOL expected
Definition: store.c:2063

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 {
242  GpStatus stat;
243  HDC hdc;
244  GpGraphics *graphics;
246 
247  state.desc = desc;
248  state.count = 0;
249  state.expected = expected;
250  state.metafile = metafile;
251 
252  hdc = CreateCompatibleDC(0);
253 
254  stat = GdipCreateFromHDC(hdc, &graphics);
255  expect(Ok, stat);
256 
257  stat = GdipEnumerateMetafileSrcRectDestPoints(graphics, metafile, dst_points,
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 }
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
static BOOL CALLBACK enum_metafile_proc(EmfPlusRecordType record_type, unsigned int flags, unsigned int dataSize, const unsigned char *pStr, void *userdata)
Definition: metafile.c:212
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define todo_wine_if(is_todo)
Definition: test.h:155
#define expect(expected, got)
Definition: metafile.c:27
HDC hdc
Definition: main.c:9
static int state
Definition: maze.c:121
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
BOOL expected
Definition: store.c:2063

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  {
57  todo_wine_if (expected->todo)
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 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
DWORD record_type
Definition: metafile.c:36
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 flags
Definition: metafile.c:37
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define todo_wine_if(is_todo)
Definition: test.h:155
GLbitfield flags
Definition: glext.h:7161
GLdouble s
Definition: gl.h:2039
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
BOOLEAN Expected
#define GDIP_EMFPLUS_RECORD_BASE
Definition: gdiplusenums.h:448
BOOL expected
Definition: store.c:2063

Referenced by enum_emf_proc(), and enum_metafile_proc().

◆ 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 }
static int CALLBACK enum_emf_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, int nObj, LPARAM lpData)
Definition: metafile.c:113
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLintptr offset
Definition: glext.h:5920
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
DWORD record_type
Definition: metafile.c:36
DWORD flags
Definition: metafile.c:37
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI EnumEnhMetaFile(_In_opt_ HDC, _In_ HENHMETAFILE, _In_ ENHMFENUMPROC, _In_opt_ PVOID, _In_opt_ LPCRECT)
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
#define EMR_GDICOMMENT
Definition: wingdi.h:143
Definition: id3.c:18
static int state
Definition: maze.c:121
#define ok(value,...)
Definition: atltest.h:57
static void check_record(int count, const char *desc, const struct emfplus_record *expected, const struct emfplus_record *actual)
Definition: metafile.c:53

Referenced by check_emfplus().

◆ 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
DWORD record_type
Definition: metafile.c:36
DWORD flags
Definition: metafile.c:37
smooth NULL
Definition: ftsmooth.c:416
GLbitfield flags
Definition: glext.h:7161
static int state
Definition: maze.c:121
#define ok(value,...)
Definition: atltest.h:57
static void check_record(int count, const char *desc, const struct emfplus_record *expected, const struct emfplus_record *actual)
Definition: metafile.c:53
GLenum GLsizei dataSize
Definition: glext.h:11123

Referenced by check_metafile().

◆ 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 {
308  GpStatus stat;
310 
311  state.desc = desc;
312  state.count = 0;
313  state.expected = expected;
314  state.metafile = metafile;
315 
316  stat = GdipEnumerateMetafileSrcRectDestPoints(graphics, metafile, dst_points,
317  3, src_rect, src_unit, play_metafile_proc, &state, NULL);
318  expect(Ok, stat);
319 }
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
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
static const unsigned char metafile[]
Definition: olepicture.c:138
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define expect(expected, got)
Definition: metafile.c:27
static int state
Definition: maze.c:121
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL expected
Definition: store.c:2063

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 {
273  GpStatus stat;
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 
299  return FALSE;
300  }
301 
302  return TRUE;
303 }
return
Definition: dirsup.c:529
#define TRUE
Definition: types.h:120
Definition: match.c:28
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL todo
Definition: filedlg.c:313
GLdouble n
Definition: glext.h:7729
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
else
Definition: tritemp.h:161
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
unsigned int BOOL
Definition: ntddk_ex.h:94
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define todo_wine_if(is_todo)
Definition: test.h:155
GLbitfield flags
Definition: glext.h:7161
static int state
Definition: maze.c:121
Definition: stat.h:55
_CRTIMP void __cdecl unexpected(void)
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define ok(value,...)
Definition: atltest.h:57
GLenum GLsizei dataSize
Definition: glext.h:11123
BOOL expected
Definition: store.c:2063
GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, EmfPlusRecordType recordType, UINT flags, UINT dataSize, GDIPCONST BYTE *data)
Definition: metafile.c:2461

Referenced by play_metafile().

◆ START_TEST()

START_TEST ( metafile  )

Definition at line 2787 of file metafile.c.

2788 {
2789  struct GdiplusStartupInput gdiplusStartupInput;
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"))
2813  save_metafiles = TRUE;
2814  else if (!strcmp(myARGV[2], "load"))
2815  load_metafiles = TRUE;
2816  }
2817 
2818  test_empty();
2819  test_getdc();
2820  test_emfonly();
2821  test_fillrect();
2822  test_clear();
2827  test_frameunit();
2828  test_containers();
2829  test_clipping();
2831  test_drawimage();
2832  test_properties();
2833  test_drawpath();
2834  test_fillpath();
2835 
2837 }
#define TRUE
Definition: types.h:120
static void test_pagetransform(void)
Definition: metafile.c:1351
static BOOL load_metafiles
Definition: metafile.c:32
static void test_properties(void)
Definition: metafile.c:2574
static void test_drawpath(void)
Definition: metafile.c:2652
static void test_emfonly(void)
Definition: metafile.c:728
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLenum GLint GLuint mask
Definition: glext.h:6028
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void test_containers(void)
Definition: metafile.c:1986
static void test_getdc(void)
Definition: metafile.c:573
smooth NULL
Definition: ftsmooth.c:416
static INT myARGC
Definition: FindFiles.c:28
static void test_fillpath(void)
Definition: metafile.c:2717
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: cntrlfp.c:120
static void test_nullframerect(void)
Definition: metafile.c:1219
void WINAPI GdiplusShutdown(ULONG_PTR)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
int winetest_get_mainargs(char ***pargv)
static ULONG_PTR gdiplusToken
Definition: CImage.cpp:79
static void test_empty(void)
Definition: metafile.c:368
static void test_clipping(void)
Definition: metafile.c:2180
static void test_clear(void)
Definition: metafile.c:1143
static void test_drawimage(void)
Definition: metafile.c:2459
#define CDECL
Definition: compat.h:21
static void test_worldtransform(void)
Definition: metafile.c:1556
static LPSTR * myARGV
Definition: FindFiles.c:29
static void test_frameunit(void)
Definition: metafile.c:1894
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static void test_gditransform(void)
Definition: metafile.c:2324
static void test_fillrect(void)
Definition: metafile.c:1029
#define GetProcAddress(x, y)
Definition: compat.h:410
static BOOL save_metafiles
Definition: metafile.c:31
static void test_converttoemfplus(void)
Definition: metafile.c:1816
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ sync_metafile()

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

Definition at line 323 of file metafile.c.

324 {
325  GpStatus stat;
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 
352  hemf = GetEnhMetaFileA(filename);
353  ok(hemf != NULL, "%s could not be opened\n", filename);
354 
356  expect(Ok, stat);
357  }
358 }
#define TRUE
Definition: types.h:120
static BOOL load_metafiles
Definition: metafile.c:32
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
Definition: image.c:1308
const char * filename
Definition: ioapi.h:135
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile)
Definition: metafile.c:3804
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
#define expect(expected, got)
Definition: metafile.c:27
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
HENHMETAFILE WINAPI CopyEnhMetaFileA(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCSTR pszFile)
#define ok(value,...)
Definition: atltest.h:57
HENHMETAFILE WINAPI GetEnhMetaFileA(_In_ LPCSTR)
static BOOL save_metafiles
Definition: metafile.c:31

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};
1153  GpBitmap *bitmap;
1154  ARGB color;
1155 
1156  hdc = CreateCompatibleDC(0);
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 
1190  stat = GdipBitmapGetPixel(bitmap, 5, 5, &color);
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 }
static const emfplus_record clear_emf_records[]
Definition: metafile.c:1130
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
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
#define PixelFormat32bppRGB
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
Definition: uimain.c:88
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
HDC hdc
Definition: main.c:9
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
Definition: graphics.c:5076
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
static HBITMAP bitmap
Definition: clipboard.c:1344
DWORD ARGB

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;
2185  GpBitmap *bitmap;
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 
2196  hdc = CreateCompatibleDC(0);
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 }
static const emfplus_record clipping_records[]
Definition: metafile.c:2164
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics *graphics, GpRectF *rect)
Definition: graphics.c:5004
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode mode)
Definition: graphics.c:6473
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
& rect
Definition: startmenu.cpp:1413
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4537
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:994
Definition: uimain.c:88
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
Definition: graphics.c:6045
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
HDC hdc
Definition: main.c:9
static int state
Definition: maze.c:121
Definition: stat.h:55
UINT GraphicsState
Definition: gdiplusenums.h:22
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, CombineMode mode)
Definition: graphics.c:6533
#define ok(value,...)
Definition: atltest.h:57
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
Definition: graphics.c:5911
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 HBITMAP bitmap
Definition: clipboard.c:1344
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:757
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
Definition: region.c:571
#define PixelFormat32bppARGB
GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect, GpRegion **region)
Definition: region.c:459
DWORD ARGB

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;
1991  GpBitmap *bitmap;
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 
2002  hdc = CreateCompatibleDC(0);
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 
2142  stat = GdipBitmapGetPixel(bitmap, 8, 8, &color);
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 }
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 GdipGetDpiX(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6621
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
UINT GraphicsContainer
Definition: gdiplusenums.h:23
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height)
Definition: graphics.c:4537
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
REAL Height
Definition: gdiplustypes.h:264
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:994
Definition: uimain.c:88
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state)
Definition: graphics.c:6039
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
REAL X
Definition: gdiplustypes.h:261
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state)
Definition: graphics.c:5917
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
Definition: graphics.c:6045
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
HDC hdc
Definition: main.c:9
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
REAL Width
Definition: gdiplustypes.h:263
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
Definition: graphics.c:5911
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 HBITMAP bitmap
Definition: clipboard.c:1344
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:757
float REAL
Definition: types.h:41
REAL Y
Definition: gdiplustypes.h:262
#define PixelFormat32bppARGB
static const emfplus_record container_records[]
Definition: metafile.c:1960
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state)
Definition: graphics.c:5924
DWORD ARGB

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 
1837  hdc = CreateCompatibleDC(0);
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);
1874  todo_wine expect(Ok, stat);
1875  if(metafile2)
1876  GdipDisposeImage((GpImage*)metafile2);
1877 
1878  succ = FALSE;
1879  stat = pGdipConvertToEmfPlus(graphics, metafile, &succ, EmfTypeEmfPlusOnly, NULL, &metafile2);
1880  todo_wine expect(Ok, stat);
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 }
Status GpStatus
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
unsigned int BOOL
Definition: ntddk_ex.h:94
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
smooth NULL
Definition: ftsmooth.c:416
#define expect(expected, got)
Definition: metafile.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINAPI
Definition: msvc.h:8
#define todo_wine
Definition: test.h:154
HDC hdc
Definition: main.c:9
Definition: stat.h:55
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
EmfType
Definition: gdiplusenums.h:230
#define GetProcAddress(x, y)
Definition: compat.h:410
#define win_skip
Definition: test.h:141
static int mod
Definition: i386-dis.c:1273

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;
2476  BITMAPINFO info;
2477  BYTE buff[400];
2478  GpImage *image;
2479  HDC hdc;
2480 
2481  hdc = CreateCompatibleDC(0);
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 }
GLeglImageOES image
Definition: gl.h:2204
#define TRUE
Definition: types.h:120
static const emfplus_record draw_image_metafile_records[]
Definition: metafile.c:2432
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
static const emfplus_record draw_image_bitmap_records[]
Definition: metafile.c:2417
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO *info, VOID *bits, GpBitmap **bitmap)
Definition: image.c:1385
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
struct _test_info info[]
Definition: SetCursorPos.c:19
GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix *colorMatrix, GDIPCONST ColorMatrix *grayMatrix, ColorMatrixFlags flags)
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile)
Definition: metafile.c:3804
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
HDC hdc
Definition: main.c:9
Definition: stat.h:55
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
unsigned char BYTE
Definition: mem.h:68
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
#define GetProcAddress(x, y)
Definition: compat.h:410
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
#define BI_RGB
Definition: precomp.h:34
static unsigned char buff[32768]
Definition: fatten.c:17
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)

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 
2665  hdc = CreateCompatibleDC(0);
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 }
GLsizei const GLchar ** path
Definition: glext.h:7234
GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
Definition: graphics.c:4066
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
GLfloat f
Definition: glext.h:7540
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
HDC hdc
Definition: main.c:9
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
static const emfplus_record draw_path_records[]
Definition: metafile.c:2637
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphicspath.c:704
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
Definition: services.c:325
GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
Definition: pen.c:192
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen)
Definition: pen.c:136
DWORD ARGB

Referenced by START_TEST().

◆ test_emfonly()

static void test_emfonly ( void  )
static

Definition at line 728 of file metafile.c.

729 {
730  GpStatus stat;
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;
744  GpBitmap *bitmap;
745  ARGB color;
746  GpPen *pen;
747 
748  hdc = CreateCompatibleDC(0);
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 
801  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
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 
943  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
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 */
991  hdc = CreateCompatibleDC(0);
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);
1007  todo_wine expect(Ok, stat);
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 const emfplus_record emfonly_records[]
Definition: metafile.c:697
#define TRUE
Definition: types.h:120
static HBRUSH hbrush
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromEmf(HENHMETAFILE hemf, MetafileHeader *header)
Definition: metafile.c:3688
Unit
Definition: gdiplusenums.h:25
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
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
Definition: image.c:2148
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
Definition: image.c:2330
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:6758
#define U(x)
Definition: wordpad.c:44
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap *bitmap, INT x, INT y, ARGB color)
Definition: image.c:494
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2261
#define expectf(expected, got)
Definition: metafile.c:29
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
Definition: image.c:1308
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2)
Definition: graphics.c:3589
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile)
Definition: metafile.c:3804
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
smooth NULL
Definition: ftsmooth.c:416
#define expectf_(expected, got, precision)
Definition: metafile.c:28
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
REAL Height
Definition: gdiplustypes.h:264
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile *metafile, MetafileHeader *header)
Definition: metafile.c:3632
Definition: uimain.c:88
GLfloat f
Definition: glext.h:7540
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
REAL X
Definition: gdiplustypes.h:261
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
Definition: graphics.c:6682
static const emfplus_record emfonly_draw_records[]
Definition: metafile.c:708
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
#define todo_wine
Definition: test.h:154
HDC hdc
Definition: main.c:9
#define EMR_HEADER
Definition: wingdi.h:75
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
REAL Width
Definition: gdiplustypes.h:263
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
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 HBITMAP bitmap
Definition: clipboard.c:1344
GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
Definition: pen.c:192
float REAL
Definition: types.h:41
REAL Y
Definition: gdiplustypes.h:262
#define memset(x, y, z)
Definition: compat.h:39
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen)
Definition: pen.c:136
struct CFHEADER header
Definition: fdi.c:109
#define PixelFormat32bppARGB
DWORD ARGB

Referenced by START_TEST().

◆ test_empty()

static void test_empty ( void  )
static

Definition at line 368 of file metafile.c.

369 {
370  GpStatus stat;
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 
383  hdc = CreateCompatibleDC(0);
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 
427  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
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 
511  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
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 }
#define TRUE
Definition: types.h:120
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromEmf(HENHMETAFILE hemf, MetafileHeader *header)
Definition: metafile.c:3688
Unit
Definition: gdiplusenums.h:25
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
Definition: image.c:2148
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
Definition: image.c:2330
#define U(x)
Definition: wordpad.c:44
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2261
#define expectf(expected, got)
Definition: metafile.c:29
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static const emfplus_record empty_records[]
Definition: metafile.c:360
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile)
Definition: metafile.c:3804
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
smooth NULL
Definition: ftsmooth.c:416
#define expectf_(expected, got, precision)
Definition: metafile.c:28
REAL Height
Definition: gdiplustypes.h:264
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile *metafile, MetafileHeader *header)
Definition: metafile.c:3632
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
REAL X
Definition: gdiplustypes.h:261
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
HDC hdc
Definition: main.c:9
#define EMR_HEADER
Definition: wingdi.h:75
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
REAL Width
Definition: gdiplustypes.h:263
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
unsigned char dummy
Definition: maze.c:118
#define ok(value,...)
Definition: atltest.h:57
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
float REAL
Definition: types.h:41
REAL Y
Definition: gdiplustypes.h:262
#define memset(x, y, z)
Definition: compat.h:39
struct CFHEADER header
Definition: fdi.c:109

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 
2731  hdc = CreateCompatibleDC(0);
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 */
2775  stat = GdipCreateMetafileFromWmfFile(winetestemfW, NULL, &metafile);
2776  expect(Ok, stat);
2777 
2779  expect(Ok, stat);
2780 
2781  DeleteFileW(winetestemfW);
2782 
2783  stat = GdipCreateMetafileFromWmfFile(winetestemfW, NULL, &metafile);
2785 }
GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)
Definition: graphics.c:4391
GLsizei const GLchar ** path
Definition: glext.h:7234
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
static const emfplus_record fill_path_records[]
Definition: metafile.c:2703
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:994
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
HENHMETAFILE WINAPI CopyEnhMetaFileW(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCWSTR pszFile)
HDC hdc
Definition: main.c:9
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
GpStatus WINGDIPAPI GdipAddPathLine(GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2)
Definition: graphicspath.c:704
static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, const char *desc)
Definition: metafile.c:198
Definition: services.c:325
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:757
GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR *file, GDIPCONST WmfPlaceableFileHeader *placeable, GpMetafile **metafile)
Definition: metafile.c:3896

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};
1040  GpBitmap *bitmap;
1041  ARGB color;
1042  GpBrush *brush;
1043 
1044  hdc = CreateCompatibleDC(0);
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 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
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap *bitmap, INT x, INT y, ARGB color)
Definition: image.c:494
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
Definition: brush.c:994
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height)
Definition: graphics.c:4552
Definition: uimain.c:88
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const emfplus_record fillrect_records[]
Definition: metafile.c:1020
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
HDC hdc
Definition: main.c:9
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
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 HBITMAP bitmap
Definition: clipboard.c:1344
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
Definition: brush.c:757
#define PixelFormat32bppARGB
DWORD ARGB

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 
1906  hdc = CreateCompatibleDC(0);
1907 
1909  expect(Ok, stat);
1910 
1911  DeleteDC(hdc);
1912 
1913  if (stat != Ok)
1914  return;
1915 
1916  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
1917  expect(Ok, stat);
1918  expect(UnitPixel, unit);
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 
1929  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
1930  expect(Ok, stat);
1931  expect(UnitPixel, unit);
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 
1948  stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
1949  expect(Ok, stat);
1950  expect(UnitPixel, unit);
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 }
Unit
Definition: gdiplusenums.h:25
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
Definition: image.c:2148
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
Definition: image.c:2330
static HDC
Definition: imagelist.c:92
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
Definition: image.c:2261
#define expectf(expected, got)
Definition: metafile.c:29
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
#define expectf_(expected, got, precision)
Definition: metafile.c:28
REAL Height
Definition: gdiplustypes.h:264
#define expect(expected, got)
Definition: metafile.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
REAL X
Definition: gdiplustypes.h:261
HDC hdc
Definition: main.c:9
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
#define broken(x)
Definition: _sntprintf.h:21
Status
Definition: gdiplustypes.h:24
REAL Width
Definition: gdiplustypes.h:263
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57
float REAL
Definition: types.h:41
REAL Y
Definition: gdiplustypes.h:262

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;
2336  GpBitmap *bitmap;
2337  ARGB color;
2338 
2339  hdc = CreateCompatibleDC(0);
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);
2355  expect(MetafileTypeEmf, header.Type);
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 HBRUSH hbrush
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:6758
static const emfplus_record gditransform_records[]
Definition: metafile.c:2313
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile *metafile, MetafileHeader *header)
Definition: metafile.c:3632
Definition: uimain.c:88
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
Definition: graphics.c:6682
BOOL WINAPI GdiComment(_In_ HDC hdc, _In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpData)
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
HDC hdc
Definition: main.c:9
Definition: stat.h:55
unsigned char BYTE
Definition: mem.h:68
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
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 HBITMAP bitmap
Definition: clipboard.c:1344
#define memset(x, y, z)
Definition: compat.h:39
struct CFHEADER header
Definition: fdi.c:109
#define PixelFormat32bppARGB
DWORD ARGB

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 }
static const unsigned char metafile[]
Definition: olepicture.c:138
#define EMR_RECTANGLE
Definition: wingdi.h:117
#define expect(expected, got)
Definition: metafile.c:27
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define EMR_SETWORLDTRANSFORM
Definition: wingdi.h:109
GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile, EmfPlusRecordType recordType, UINT flags, UINT dataSize, GDIPCONST BYTE *data)
Definition: metafile.c:2461

◆ test_getdc()

static void test_getdc ( void  )
static

Definition at line 573 of file metafile.c.

574 {
575  GpStatus stat;
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;
586  GpBitmap *bitmap;
587  ARGB color;
588 
589  hdc = CreateCompatibleDC(0);
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 HBRUSH hbrush
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
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
Definition: graphics.c:6758
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static const emfplus_record getdc_records[]
Definition: metafile.c:559
GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE *hEmf)
Definition: metafile.c:1613
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap *bitmap, INT x, INT y, ARGB color)
Definition: image.c:494
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, GpGraphics **graphics)
Definition: image.c:2201
const char * description
Definition: directx.c:2497
GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
Definition: metafile.c:735
static const unsigned char metafile[]
Definition: olepicture.c:138
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint color
Definition: glext.h:6243
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
Definition: uimain.c:88
#define expect(expected, got)
Definition: metafile.c:27
static void sync_metafile(GpMetafile **metafile, const char *filename)
Definition: metafile.c:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
Definition: graphics.c:6682
int ret
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
HDC hdc
Definition: main.c:9
Definition: stat.h:55
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
BOOL WINAPI DeleteDC(_In_ HDC)
#define ok(value,...)
Definition: atltest.h:57