From 90bfb3a5eee1f536c1b8fa584c30b4b3ca52cc8c Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 21 May 2011 17:48:32 -0500 Subject: [PATCH 4/5] gdiplus: Implement GdipEnumerateMetafileSrcRectDestPoints. --- dlls/gdiplus/metafile.c | 67 +++++++++++++++++++++++++++++++++++++++- dlls/gdiplus/tests/metafile.c | 4 +- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index a34ce76..e84cef0 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -323,22 +323,85 @@ GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile *metafile, HENHMETAFILE * return Ok; } +struct enum_metafile_data +{ + EnumerateMetafileProc callback; + void *callback_data; +}; + +static int CALLBACK enum_metafile_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, + int nObj, LPARAM lpData) +{ + BOOL ret; + struct enum_metafile_data *data = (struct enum_metafile_data*)lpData; + const BYTE* pStr; + + /* First check for an EMF+ record. */ + if (lpEMFR->iType == EMR_GDICOMMENT) + { + const EMRGDICOMMENT *comment = (const EMRGDICOMMENT*)lpEMFR; + + if (comment->cbData >= 4 && memcmp(comment->Data, "EMF+", 4) == 0) + { + int offset = 4; + + while (offset + sizeof(EmfPlusRecordHeader) <= comment->cbData) + { + const EmfPlusRecordHeader *record = (const EmfPlusRecordHeader*)&comment->Data[offset]; + + if (record->DataSize) + pStr = (const BYTE*)(record+1); + else + pStr = NULL; + + ret = data->callback(record->Type, record->Flags, record->DataSize, + pStr, data->callback_data); + + if (!ret) + return 0; + + offset += record->Size; + } + + return 1; + } + } + + if (lpEMFR->nSize != 8) + pStr = (const BYTE*)lpEMFR->dParm; + else + pStr = NULL; + + return data->callback(lpEMFR->iType, 0, lpEMFR->nSize-8, + pStr, data->callback_data); +} + 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) { - FIXME("(%p,%p,%p,%i,%p,%i,%p,%p,%p): stub\n", graphics, metafile, + struct enum_metafile_data data; + + TRACE("(%p,%p,%p,%i,%p,%i,%p,%p,%p)\n", graphics, metafile, destPoints, count, srcRect, srcUnit, callback, callbackData, imageAttributes); if (!graphics || !metafile || !destPoints || count != 3 || !srcRect) return InvalidParameter; + if (!metafile->hemf) + return InvalidParameter; + TRACE("%s %i -> %s %s %s\n", debugstr_rectf(srcRect), srcUnit, debugstr_pointf(&destPoints[0]), debugstr_pointf(&destPoints[1]), debugstr_pointf(&destPoints[2])); - return NotImplemented; + data.callback = callback; + data.callback_data = callbackData; + + EnumEnhMetaFile(0, metafile->hemf, enum_metafile_proc, &data, NULL); + + return Ok; } diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index ff9c346..30fdf64 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -178,9 +178,9 @@ static void check_metafile(GpMetafile *metafile, const emfplus_record *expected, stat = GdipEnumerateMetafileSrcRectDestPoints(graphics, metafile, dst_points, 3, src_rect, src_unit, enum_metafile_proc, &state, NULL); - todo_wine expect(Ok, stat); + expect(Ok, stat); - todo_wine ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count); + ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count); GdipDeleteGraphics(graphics); -- 1.7.2.5