Module: wine Branch: master Commit: 592533bd72aa9046c64117fa3258937611939f42 URL: http://source.winehq.org/git/wine.git/?a=commit;h=592533bd72aa9046c64117fa32...
Author: Vincent Povirk vincent@codeweavers.com Date: Fri Oct 30 14:55:32 2015 -0500
gdiplus: Use GdipGetMetafileHeaderFromEmf when opening metafiles.
Signed-off-by: Vincent Povirk vincent@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/gdiplus/metafile.c | 70 +++++++++---------------------------------- dlls/gdiplus/tests/metafile.c | 20 ++++++------- 2 files changed, 24 insertions(+), 66 deletions(-)
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index ca9889b..6d7048a 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -887,46 +887,6 @@ GpStatus WINGDIPAPI GdipEnumerateMetafileDestPointI(GpGraphics *graphics, return GdipEnumerateMetafileDestPoint(graphics, metafile, &ptf, callback, cb_data, attrs); }
-static int CALLBACK get_metafile_type_proc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, - int nObj, LPARAM lpData) -{ - MetafileType *result = (MetafileType*)lpData; - - if (lpEMFR->iType == EMR_GDICOMMENT) - { - const EMRGDICOMMENT *comment = (const EMRGDICOMMENT*)lpEMFR; - - if (comment->cbData >= 4 && memcmp(comment->Data, "EMF+", 4) == 0) - { - const EmfPlusRecordHeader *header = (const EmfPlusRecordHeader*)&comment->Data[4]; - - if (4 + sizeof(EmfPlusRecordHeader) <= comment->cbData && - header->Type == EmfPlusRecordTypeHeader) - { - if ((header->Flags & 1) == 1) - *result = MetafileTypeEmfPlusDual; - else - *result = MetafileTypeEmfPlusOnly; - } - } - else - *result = MetafileTypeEmf; - } - else if (lpEMFR->iType == EMR_HEADER) - return TRUE; - else - *result = MetafileTypeEmf; - - return FALSE; -} - -static MetafileType METAFILE_GetEmfType(HENHMETAFILE hemf) -{ - MetafileType result = MetafileTypeInvalid; - EnumEnhMetaFile(NULL, hemf, get_metafile_type_proc, &result, NULL); - return result; -} - GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile * metafile, MetafileHeader * header) { @@ -1069,21 +1029,17 @@ GpStatus WINGDIPAPI GdipGetMetafileHeaderFromStream(IStream *stream, GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile) { - ENHMETAHEADER header; - MetafileType metafile_type; + GpStatus stat; + MetafileHeader header;
TRACE("(%p,%i,%p)\n", hemf, delete, metafile);
if(!hemf || !metafile) return InvalidParameter;
- if (GetEnhMetaFileHeader(hemf, sizeof(header), &header) == 0) - return GenericError; - - metafile_type = METAFILE_GetEmfType(hemf); - - if (metafile_type == MetafileTypeInvalid) - return GenericError; + stat = GdipGetMetafileHeaderFromEmf(hemf, &header); + if (stat != Ok) + return stat;
*metafile = heap_alloc_zero(sizeof(GpMetafile)); if (!*metafile) @@ -1092,14 +1048,16 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, (*metafile)->image.type = ImageTypeMetafile; (*metafile)->image.format = ImageFormatEMF; (*metafile)->image.frame_count = 1; - (*metafile)->image.xres = (REAL)header.szlDevice.cx; - (*metafile)->image.yres = (REAL)header.szlDevice.cy; - (*metafile)->bounds.X = (REAL)header.rclBounds.left; - (*metafile)->bounds.Y = (REAL)header.rclBounds.top; - (*metafile)->bounds.Width = (REAL)(header.rclBounds.right - header.rclBounds.left); - (*metafile)->bounds.Height = (REAL)(header.rclBounds.bottom - header.rclBounds.top); + (*metafile)->image.xres = header.DpiX; + (*metafile)->image.yres = header.DpiY; + (*metafile)->bounds.X = (REAL)header.EmfHeader.rclFrame.left / 2540.0 * header.DpiX; + (*metafile)->bounds.Y = (REAL)header.EmfHeader.rclFrame.top / 2540.0 * header.DpiY; + (*metafile)->bounds.Width = (REAL)(header.EmfHeader.rclFrame.right - header.EmfHeader.rclFrame.left) + / 2540.0 * header.DpiX; + (*metafile)->bounds.Height = (REAL)(header.EmfHeader.rclFrame.bottom - header.EmfHeader.rclFrame.top) + / 2540.0 * header.DpiY; (*metafile)->unit = UnitPixel; - (*metafile)->metafile_type = metafile_type; + (*metafile)->metafile_type = header.Type; (*metafile)->hemf = hemf; (*metafile)->preserve_hemf = !delete;
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 5a7d037..a4b3f59 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -401,17 +401,17 @@ static void test_empty(void) expect(Ok, stat); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); - todo_wine expectf_(100.0, bounds.Width, 0.05); - todo_wine expectf_(100.0, bounds.Height, 0.05); + expectf_(100.0, bounds.Width, 0.05); + expectf_(100.0, bounds.Height, 0.05); expect(UnitPixel, unit);
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &xres); expect(Ok, stat); - todo_wine expectf(header.DpiX, xres); + expectf(header.DpiX, xres);
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &yres); expect(Ok, stat); - todo_wine expectf(header.DpiY, yres); + expectf(header.DpiY, yres);
stat = GdipDisposeImage((GpImage*)metafile); expect(Ok, stat); @@ -746,19 +746,19 @@ static void test_emfonly(void)
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit); expect(Ok, stat); - todo_wine expectf(0.0, bounds.X); - todo_wine expectf(0.0, bounds.Y); - todo_wine expectf_(100.0, bounds.Width, 0.05); - todo_wine expectf_(100.0, bounds.Height, 0.05); + expectf(0.0, bounds.X); + expectf(0.0, bounds.Y); + expectf_(100.0, bounds.Width, 0.05); + expectf_(100.0, bounds.Height, 0.05); expect(UnitPixel, unit);
stat = GdipGetImageHorizontalResolution((GpImage*)metafile, &xres); expect(Ok, stat); - todo_wine expectf(header.DpiX, xres); + expectf(header.DpiX, xres);
stat = GdipGetImageVerticalResolution((GpImage*)metafile, &yres); expect(Ok, stat); - todo_wine expectf(header.DpiY, yres); + expectf(header.DpiY, yres);
stat = GdipDisposeImage((GpImage*)metafile); expect(Ok, stat);