gdiplus: Implement writing SetPageTransform records.

This commit is contained in:
Vincent Povirk 2014-01-16 15:43:45 -06:00 committed by Alexandre Julliard
parent 55ad831598
commit 6518edfa5f
3 changed files with 48 additions and 0 deletions

View File

@ -59,6 +59,7 @@ extern GpStatus METAFILE_GetDC(GpMetafile* metafile, HDC *hdc) DECLSPEC_HIDDEN;
extern GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) DECLSPEC_HIDDEN; extern GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) DECLSPEC_HIDDEN;
extern GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush, extern GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush,
GDIPCONST GpRectF* rects, INT count) DECLSPEC_HIDDEN; GDIPCONST GpRectF* rects, INT count) DECLSPEC_HIDDEN;
extern GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale) DECLSPEC_HIDDEN;
extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN; extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN;
extern MetafileType METAFILE_GetEmfType(HENHMETAFILE hemf) DECLSPEC_HIDDEN; extern MetafileType METAFILE_GetEmfType(HENHMETAFILE hemf) DECLSPEC_HIDDEN;

View File

@ -5274,6 +5274,8 @@ GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics,
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale) GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
{ {
GpStatus stat;
TRACE("(%p, %.2f)\n", graphics, scale); TRACE("(%p, %.2f)\n", graphics, scale);
if(!graphics || (scale <= 0.0)) if(!graphics || (scale <= 0.0))
@ -5282,6 +5284,13 @@ GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
if(graphics->busy) if(graphics->busy)
return ObjectBusy; return ObjectBusy;
if (graphics->image && graphics->image->type == ImageTypeMetafile)
{
stat = METAFILE_SetPageTransform((GpMetafile*)graphics->image, graphics->unit, scale);
if (stat != Ok)
return stat;
}
graphics->scale = scale; graphics->scale = scale;
return Ok; return Ok;
@ -5289,6 +5298,8 @@ GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit) GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
{ {
GpStatus stat;
TRACE("(%p, %d)\n", graphics, unit); TRACE("(%p, %d)\n", graphics, unit);
if(!graphics) if(!graphics)
@ -5300,6 +5311,13 @@ GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
if(unit == UnitWorld) if(unit == UnitWorld)
return InvalidParameter; return InvalidParameter;
if (graphics->image && graphics->image->type == ImageTypeMetafile)
{
stat = METAFILE_SetPageTransform((GpMetafile*)graphics->image, unit, graphics->scale);
if (stat != Ok)
return stat;
}
graphics->unit = unit; graphics->unit = unit;
return Ok; return Ok;

View File

@ -64,6 +64,12 @@ typedef struct EmfPlusFillRects
DWORD Count; DWORD Count;
} EmfPlusFillRects; } EmfPlusFillRects;
typedef struct EmfPlusSetPageTransform
{
EmfPlusRecordHeader Header;
REAL PageScale;
} EmfPlusSetPageTransform;
typedef struct EmfPlusRect typedef struct EmfPlusRect
{ {
SHORT X; SHORT X;
@ -416,6 +422,29 @@ GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush,
return Ok; return Ok;
} }
GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale)
{
if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual)
{
EmfPlusSetPageTransform *record;
GpStatus stat;
stat = METAFILE_AllocateRecord(metafile,
sizeof(EmfPlusSetPageTransform),
(void**)&record);
if (stat != Ok)
return stat;
record->Header.Type = EmfPlusRecordTypeSetPageTransform;
record->Header.Flags = unit;
record->PageScale = scale;
METAFILE_WriteRecords(metafile);
}
return Ok;
}
GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc)
{ {
if (hdc != metafile->record_dc) if (hdc != metafile->record_dc)