gdiplus: Implement GdipCloneImage for metafiles with a handle.
This commit is contained in:
parent
0cbec5508b
commit
d8a855305f
|
@ -1382,10 +1382,40 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
|
|||
|
||||
return stat;
|
||||
}
|
||||
else if (image->type == ImageTypeMetafile && ((GpMetafile*)image)->hemf)
|
||||
{
|
||||
GpMetafile *result, *metafile;
|
||||
|
||||
metafile = (GpMetafile*)image;
|
||||
|
||||
result = GdipAlloc(sizeof(*result));
|
||||
if (!result)
|
||||
return OutOfMemory;
|
||||
|
||||
result->image.type = ImageTypeMetafile;
|
||||
result->image.format = image->format;
|
||||
result->image.flags = image->flags;
|
||||
result->image.frame_count = 1;
|
||||
result->image.xres = image->xres;
|
||||
result->image.yres = image->yres;
|
||||
result->bounds = metafile->bounds;
|
||||
result->unit = metafile->unit;
|
||||
result->metafile_type = metafile->metafile_type;
|
||||
result->hemf = CopyEnhMetaFileW(metafile->hemf, NULL);
|
||||
|
||||
if (!result->hemf)
|
||||
{
|
||||
GdipFree(result);
|
||||
return OutOfMemory;
|
||||
}
|
||||
|
||||
*cloneImage = &result->image;
|
||||
return Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("GpImage with no IPicture or bitmap?!\n");
|
||||
return NotImplemented;
|
||||
WARN("GpImage with no image data (metafile in wrong state?)\n");
|
||||
return InvalidParameter;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -474,6 +474,7 @@ static void test_emfonly(void)
|
|||
{
|
||||
GpStatus stat;
|
||||
GpMetafile *metafile;
|
||||
GpImage *clone;
|
||||
GpGraphics *graphics;
|
||||
HDC hdc, metafile_dc;
|
||||
HENHMETAFILE hemf;
|
||||
|
@ -560,6 +561,29 @@ static void test_emfonly(void)
|
|||
expect(Ok, stat);
|
||||
expect(0xff0000ff, color);
|
||||
|
||||
stat = GdipCloneImage((GpImage*)metafile, &clone);
|
||||
expect(Ok, stat);
|
||||
|
||||
if (stat == Ok)
|
||||
{
|
||||
stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipDrawImagePointsRect(graphics, clone, dst_points, 3,
|
||||
0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0, color);
|
||||
|
||||
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xff0000ff, color);
|
||||
|
||||
GdipDisposeImage(clone);
|
||||
}
|
||||
|
||||
stat = GdipDeleteGraphics(graphics);
|
||||
expect(Ok, stat);
|
||||
|
||||
|
|
Loading…
Reference in New Issue