Module: wine Branch: master Commit: fd9c5d7d01d3a484c51f0d96ce802f67adb3abcc URL: http://source.winehq.org/git/wine.git/?a=commit;h=fd9c5d7d01d3a484c51f0d96ce...
Author: Vincent Povirk vincent@codeweavers.com Date: Sat May 21 17:48:32 2011 -0500
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 665d1a3..26dba93 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -323,21 +323,84 @@ 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);