From: Vincent Povirk vincent@codeweavers.com
--- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/metafile.c | 22 ++++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 25 +++++++++++++++++++++++++ include/gdiplusflat.h | 1 + 5 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 43dc0a82d2b..a722ab7b237 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -298,7 +298,7 @@ 298 stdcall GdipGetLogFontA(ptr ptr ptr) 299 stdcall GdipGetLogFontW(ptr ptr ptr) 300 stdcall GdipGetMatrixElements(ptr ptr) -301 stub GdipGetMetafileDownLevelRasterizationLimit +301 stdcall GdipGetMetafileDownLevelRasterizationLimit(ptr ptr) 302 stdcall GdipGetMetafileHeaderFromEmf(ptr ptr) 303 stdcall GdipGetMetafileHeaderFromFile(wstr ptr) 304 stdcall GdipGetMetafileHeaderFromMetafile(ptr ptr) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 39caf1a91e4..9e90a5d28cf 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -407,6 +407,7 @@ struct GpMetafile{ BOOL auto_frame; /* If true, determine the frame automatically */ GpPointF auto_frame_min, auto_frame_max; DWORD next_object_id; + UINT limit_dpi;
/* playback */ GpGraphics *playback_graphics; diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 2cb1c5f2847..3fdbc69fdc5 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -810,6 +810,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF (*metafile)->comment_data = NULL; (*metafile)->comment_data_size = 0; (*metafile)->comment_data_length = 0; + (*metafile)->limit_dpi = 96; (*metafile)->hemf = NULL; list_init(&(*metafile)->containers);
@@ -4006,11 +4007,32 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromStream(IStream *stream, return Ok; }
+GpStatus WINGDIPAPI GdipGetMetafileDownLevelRasterizationLimit(GDIPCONST GpMetafile *metafile, + UINT *limitDpi) +{ + TRACE("(%p,%p)\n", metafile, limitDpi); + + if (!metafile || !limitDpi) + return InvalidParameter; + + if (!metafile->record_dc) + return WrongState; + + *limitDpi = metafile->limit_dpi; + + return Ok; +} + GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpMetafile *metafile, UINT limitDpi) { TRACE("(%p,%u)\n", metafile, limitDpi);
+ if (!metafile) + return InvalidParameter; + + metafile->limit_dpi = limitDpi; + return Ok; }
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 49adbf71e30..b9dc33fce35 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -379,6 +379,7 @@ static void test_empty(void) static const GpRectF frame = {0.0, 0.0, 100.0, 100.0}; static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}}; static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0}; + UINT limit_dpi;
hdc = CreateCompatibleDC(0);
@@ -408,6 +409,25 @@ static void test_empty(void) if (stat != Ok) return;
+ stat = GdipGetMetafileDownLevelRasterizationLimit(metafile, NULL); + expect(InvalidParameter, stat); + + stat = GdipGetMetafileDownLevelRasterizationLimit(NULL, &limit_dpi); + expect(InvalidParameter, stat); + + limit_dpi = 0xdeadbeef; + stat = GdipGetMetafileDownLevelRasterizationLimit(metafile, &limit_dpi); + expect(Ok, stat); + ok(limit_dpi == 96, "limit_dpi was %d\n", limit_dpi); + + stat = GdipSetMetafileDownLevelRasterizationLimit(metafile, 255); + expect(Ok, stat); + + limit_dpi = 0xdeadbeef; + stat = GdipGetMetafileDownLevelRasterizationLimit(metafile, &limit_dpi); + expect(Ok, stat); + ok(limit_dpi == 255, "limit_dpi was %d\n", limit_dpi); + stat = GdipGetHemfFromMetafile(metafile, &hemf); expect(InvalidParameter, stat);
@@ -420,6 +440,11 @@ static void test_empty(void) stat = GdipDeleteGraphics(graphics); expect(Ok, stat);
+ limit_dpi = 0xdeadbeef; + stat = GdipGetMetafileDownLevelRasterizationLimit(metafile, &limit_dpi); + expect(WrongState, stat); + expect(0xdeadbeef, limit_dpi); + check_metafile(metafile, empty_records, "empty metafile", dst_points, &frame, UnitPixel);
sync_metafile(&metafile, "empty.emf"); diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index ed0f498483e..b7da5427d4e 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -545,6 +545,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR*, GDIPCONST Wm GpMetafile**); GpStatus WINGDIPAPI GdipCreateMetafileFromFile(GDIPCONST WCHAR*,GpMetafile**); GpStatus WINGDIPAPI GdipCreateMetafileFromStream(IStream*,GpMetafile**); +GpStatus WINGDIPAPI GdipGetMetafileDownLevelRasterizationLimit(GDIPCONST GpMetafile*,UINT*); GpStatus WINGDIPAPI GdipGetHemfFromMetafile(GpMetafile*,HENHMETAFILE*); GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile*,EmfPlusRecordType,UINT,UINT,GDIPCONST BYTE*); GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpMetafile*,UINT);