gdiplus: GdipCreateMetafileFromWmfFile will also load EMFs.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2017-08-16 14:32:00 -05:00 committed by Alexandre Julliard
parent aac33dab2a
commit a4ab858a96
2 changed files with 27 additions and 3 deletions

View File

@ -2361,13 +2361,20 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR *file, GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR *file,
GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile) GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile)
{ {
HMETAFILE hmf = GetMetaFileW(file); HMETAFILE hmf;
HENHMETAFILE emf;
TRACE("(%s, %p, %p)\n", debugstr_w(file), placeable, metafile); TRACE("(%s, %p, %p)\n", debugstr_w(file), placeable, metafile);
if(!hmf) return InvalidParameter; hmf = GetMetaFileW(file);
if(hmf)
return GdipCreateMetafileFromWmf(hmf, TRUE, placeable, metafile); return GdipCreateMetafileFromWmf(hmf, TRUE, placeable, metafile);
emf = GetEnhMetaFileW(file);
if(emf)
return GdipCreateMetafileFromEmf(emf, TRUE, metafile);
return GenericError;
} }
GpStatus WINGDIPAPI GdipCreateMetafileFromFile(GDIPCONST WCHAR *file, GpStatus WINGDIPAPI GdipCreateMetafileFromFile(GDIPCONST WCHAR *file,

View File

@ -2702,6 +2702,7 @@ static void test_fillpath(void)
{ {
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0}; static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0}; static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
static const WCHAR winetestemfW[] = {'w','i','n','e','t','e','s','t','.','e','m','f',0};
GpMetafile *metafile; GpMetafile *metafile;
GpGraphics *graphics; GpGraphics *graphics;
@ -2745,10 +2746,26 @@ static void test_fillpath(void)
expect(Ok, stat); expect(Ok, stat);
check_emfplus(hemf, fill_path_records, "fill path"); check_emfplus(hemf, fill_path_records, "fill path");
/* write to disk */
DeleteEnhMetaFile(CopyEnhMetaFileW(hemf, winetestemfW));
DeleteEnhMetaFile(hemf); DeleteEnhMetaFile(hemf);
stat = GdipDisposeImage((GpImage*)metafile); stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat); expect(Ok, stat);
/* should succeed when given path to an EMF */
stat = GdipCreateMetafileFromWmfFile(winetestemfW, NULL, &metafile);
expect(Ok, stat);
stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat);
DeleteFileW(winetestemfW);
stat = GdipCreateMetafileFromWmfFile(winetestemfW, NULL, &metafile);
expect(GenericError, stat);
} }
START_TEST(metafile) START_TEST(metafile)