Signed-off-by: Chao Long longchao@uniontech.com --- dlls/gdiplus/metafile.c | 205 ++++++++++++++++++++-------------------- 1 file changed, 103 insertions(+), 102 deletions(-)
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index d506d0dc8bf..5ff6b113c3d 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -759,109 +759,10 @@ static GpStatus METAFILE_WriteEndOfFile(GpMetafile *metafile) GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile) { - HDC record_dc; - REAL dpix, dpiy; - REAL framerect_factor_x, framerect_factor_y; - RECT rc, *lprc; - GpStatus stat;
TRACE("(%p %d %s %d %p %p)\n", hdc, type, debugstr_rectf(frameRect), frameUnit, desc, metafile);
- if (!hdc || type < EmfTypeEmfOnly || type > EmfTypeEmfPlusDual || !metafile) - return InvalidParameter; - - dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4; - dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4; - - if (frameRect) - { - switch (frameUnit) - { - case MetafileFrameUnitPixel: - framerect_factor_x = 2540.0 / dpix; - framerect_factor_y = 2540.0 / dpiy; - break; - case MetafileFrameUnitPoint: - framerect_factor_x = framerect_factor_y = 2540.0 / 72.0; - break; - case MetafileFrameUnitInch: - framerect_factor_x = framerect_factor_y = 2540.0; - break; - case MetafileFrameUnitDocument: - framerect_factor_x = framerect_factor_y = 2540.0 / 300.0; - break; - case MetafileFrameUnitMillimeter: - framerect_factor_x = framerect_factor_y = 100.0; - break; - case MetafileFrameUnitGdi: - framerect_factor_x = framerect_factor_y = 1.0; - break; - default: - return InvalidParameter; - } - - rc.left = framerect_factor_x * frameRect->X; - rc.top = framerect_factor_y * frameRect->Y; - rc.right = rc.left + framerect_factor_x * frameRect->Width; - rc.bottom = rc.top + framerect_factor_y * frameRect->Height; - - lprc = &rc; - } - else - lprc = NULL; - - record_dc = CreateEnhMetaFileW(hdc, NULL, lprc, desc); - - if (!record_dc) - return GenericError; - - *metafile = heap_alloc_zero(sizeof(GpMetafile)); - if(!*metafile) - { - DeleteEnhMetaFile(CloseEnhMetaFile(record_dc)); - return OutOfMemory; - } - - (*metafile)->image.type = ImageTypeMetafile; - (*metafile)->image.flags = ImageFlagsNone; - (*metafile)->image.palette = NULL; - (*metafile)->image.xres = dpix; - (*metafile)->image.yres = dpiy; - (*metafile)->bounds.X = (*metafile)->bounds.Y = 0.0; - (*metafile)->bounds.Width = (*metafile)->bounds.Height = 1.0; - (*metafile)->unit = UnitPixel; - (*metafile)->metafile_type = type; - (*metafile)->record_dc = record_dc; - (*metafile)->comment_data = NULL; - (*metafile)->comment_data_size = 0; - (*metafile)->comment_data_length = 0; - (*metafile)->limit_dpi = 96; - (*metafile)->hemf = NULL; - (*metafile)->printer_display = (GetDeviceCaps(record_dc, TECHNOLOGY) == DT_RASPRINTER); - (*metafile)->logical_dpix = (REAL)GetDeviceCaps(record_dc, LOGPIXELSX); - (*metafile)->logical_dpiy = (REAL)GetDeviceCaps(record_dc, LOGPIXELSY); - list_init(&(*metafile)->containers); - - if (!frameRect) - { - (*metafile)->auto_frame = TRUE; - (*metafile)->auto_frame_min.X = 0; - (*metafile)->auto_frame_min.Y = 0; - (*metafile)->auto_frame_max.X = -1; - (*metafile)->auto_frame_max.Y = -1; - } - - stat = METAFILE_WriteHeader(*metafile, hdc); - - if (stat != Ok) - { - DeleteEnhMetaFile(CloseEnhMetaFile(record_dc)); - heap_free(*metafile); - *metafile = NULL; - return OutOfMemory; - } - - return stat; + return GdipRecordMetafileFileName(NULL, hdc, type, frameRect, frameUnit, desc, metafile); }
/***************************************************************************** @@ -4266,10 +4167,110 @@ GpStatus WINGDIPAPI GdipRecordMetafileFileName(GDIPCONST WCHAR* fileName, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile) { - FIXME("%s %p %d %s %d %s %p stub!\n", debugstr_w(fileName), hdc, type, debugstr_rectf(pFrameRect), + HDC record_dc; + REAL dpix, dpiy; + REAL framerect_factor_x, framerect_factor_y; + RECT rc, *lprc; + GpStatus stat; + + TRACE("%s %p %d %s %d %s %p\n", debugstr_w(fileName), hdc, type, debugstr_rectf(pFrameRect), frameUnit, debugstr_w(desc), metafile);
- return NotImplemented; + if (!hdc || type < EmfTypeEmfOnly || type > EmfTypeEmfPlusDual || !metafile) + return InvalidParameter; + + dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4; + dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4; + + if (pFrameRect) + { + switch (frameUnit) + { + case MetafileFrameUnitPixel: + framerect_factor_x = 2540.0 / dpix; + framerect_factor_y = 2540.0 / dpiy; + break; + case MetafileFrameUnitPoint: + framerect_factor_x = framerect_factor_y = 2540.0 / 72.0; + break; + case MetafileFrameUnitInch: + framerect_factor_x = framerect_factor_y = 2540.0; + break; + case MetafileFrameUnitDocument: + framerect_factor_x = framerect_factor_y = 2540.0 / 300.0; + break; + case MetafileFrameUnitMillimeter: + framerect_factor_x = framerect_factor_y = 100.0; + break; + case MetafileFrameUnitGdi: + framerect_factor_x = framerect_factor_y = 1.0; + break; + default: + return InvalidParameter; + } + + rc.left = framerect_factor_x * pFrameRect->X; + rc.top = framerect_factor_y * pFrameRect->Y; + rc.right = rc.left + framerect_factor_x * pFrameRect->Width; + rc.bottom = rc.top + framerect_factor_y * pFrameRect->Height; + + lprc = &rc; + } + else + lprc = NULL; + + record_dc = CreateEnhMetaFileW(hdc, fileName, lprc, desc); + + if (!record_dc) + return GenericError; + + *metafile = heap_alloc_zero(sizeof(GpMetafile)); + if(!*metafile) + { + DeleteEnhMetaFile(CloseEnhMetaFile(record_dc)); + return OutOfMemory; + } + + (*metafile)->image.type = ImageTypeMetafile; + (*metafile)->image.flags = ImageFlagsNone; + (*metafile)->image.palette = NULL; + (*metafile)->image.xres = dpix; + (*metafile)->image.yres = dpiy; + (*metafile)->bounds.X = (*metafile)->bounds.Y = 0.0; + (*metafile)->bounds.Width = (*metafile)->bounds.Height = 1.0; + (*metafile)->unit = UnitPixel; + (*metafile)->metafile_type = type; + (*metafile)->record_dc = record_dc; + (*metafile)->comment_data = NULL; + (*metafile)->comment_data_size = 0; + (*metafile)->comment_data_length = 0; + (*metafile)->limit_dpi = 96; + (*metafile)->hemf = NULL; + (*metafile)->printer_display = (GetDeviceCaps(record_dc, TECHNOLOGY) == DT_RASPRINTER); + (*metafile)->logical_dpix = (REAL)GetDeviceCaps(record_dc, LOGPIXELSX); + (*metafile)->logical_dpiy = (REAL)GetDeviceCaps(record_dc, LOGPIXELSY); + list_init(&(*metafile)->containers); + + if (!pFrameRect) + { + (*metafile)->auto_frame = TRUE; + (*metafile)->auto_frame_min.X = 0; + (*metafile)->auto_frame_min.Y = 0; + (*metafile)->auto_frame_max.X = -1; + (*metafile)->auto_frame_max.Y = -1; + } + + stat = METAFILE_WriteHeader(*metafile, hdc); + + if (stat != Ok) + { + DeleteEnhMetaFile(CloseEnhMetaFile(record_dc)); + heap_free(*metafile); + *metafile = NULL; + return OutOfMemory; + } + + return stat; }
GpStatus WINGDIPAPI GdipRecordMetafileFileNameI(GDIPCONST WCHAR* fileName, HDC hdc, EmfType type,