From e502a8dd071d69065e2c23eeef3d7c847ce81e9e Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 13 Jul 2017 11:53:48 +0200 Subject: [PATCH] gdiplus: Add helper for saving path objects in metafile. Signed-off-by: Piotr Caban Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- dlls/gdiplus/metafile.c | 63 ++++++++++++++++++++++++++++++++++- dlls/gdiplus/tests/metafile.c | 2 +- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 2c3be422eb7..ee1efa1274a 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -157,6 +157,17 @@ typedef struct container GpRegion *clip; } container; +typedef struct EmfPlusPath +{ + DWORD Version; + DWORD PathPointCount; + DWORD PathPointFlags; + /* PathPoints[] */ + /* PathPointTypes[] */ + /* AlignmentPadding */ + BYTE data[1]; +} EmfPlusPath; + typedef enum { BitmapDataTypePixel, @@ -235,6 +246,7 @@ typedef struct EmfPlusObject EmfPlusRecordHeader Header; union { + EmfPlusPath path; EmfPlusImage image; EmfPlusImageAttributes image_attributes; } ObjectData; @@ -2570,8 +2582,57 @@ GpStatus METAFILE_AddSimpleProperty(GpMetafile *metafile, SHORT prop, SHORT val) return Ok; } +static GpStatus METAFILE_AddPathObject(GpMetafile *metafile, GpPath *path, DWORD *id) +{ + EmfPlusObject *object_record; + EmfPlusPointF *points; + BYTE *types; + GpStatus stat; + DWORD i, size; + + if (metafile->metafile_type != MetafileTypeEmfPlusOnly && metafile->metafile_type != MetafileTypeEmfPlusDual) + return Ok; + + /* TODO: Add support for more point formats */ + size = sizeof(EmfPlusPointF)*path->pathdata.Count + path->pathdata.Count; + size = (size + 3) & ~3; + + stat = METAFILE_AllocateRecord(metafile, + FIELD_OFFSET(EmfPlusObject, ObjectData.path.data[size]), + (void**)&object_record); + if (stat != Ok) return stat; + + *id = METAFILE_AddObjectId(metafile); + object_record->Header.Type = EmfPlusRecordTypeObject; + object_record->Header.Flags = *id | ObjectTypePath << 8; + + object_record->ObjectData.path.Version = 0xDBC01002; + object_record->ObjectData.path.PathPointCount = path->pathdata.Count; + object_record->ObjectData.path.PathPointFlags = 0; + + points = (EmfPlusPointF*)object_record->ObjectData.path.data; + for (i=0; ipathdata.Count; i++) + { + points[i].X = path->pathdata.Points[i].X; + points[i].Y = path->pathdata.Points[i].Y; + } + + types = (BYTE*)(points + path->pathdata.Count); + for (i=0; ipathdata.Count; i++) + types[i] = path->pathdata.Types[i]; + return Ok; +} + GpStatus METAFILE_DrawPath(GpMetafile *metafile, GpPen *pen, GpPath *path) { - FIXME("stub\n"); + DWORD path_id; + GpStatus stat; + + FIXME("stub!\n"); + + stat = METAFILE_AddPathObject(metafile, path, &path_id); + if (stat != Ok) return stat; + + METAFILE_WriteRecords(metafile); return NotImplemented; } diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 805db910044..1d3a35d11d2 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -2486,7 +2486,7 @@ static void test_properties(void) static const emfplus_record draw_path_records[] = { {0, EMR_HEADER}, {0, EmfPlusRecordTypeHeader}, - {1, EmfPlusRecordTypeObject}, + {0, EmfPlusRecordTypeObject}, {1, EmfPlusRecordTypeObject}, {1, EmfPlusRecordTypeDrawPath}, {1, EMR_SAVEDC},