gdiplus: Added GdipGetPathWorldBounds.

This commit is contained in:
Evan Stade 2007-07-11 18:08:10 -07:00 committed by Alexandre Julliard
parent 1f1ecfb2b5
commit 78510e70e7
5 changed files with 74 additions and 1 deletions

View File

@ -330,7 +330,7 @@
@ stdcall GdipGetPathPoints(ptr ptr long) @ stdcall GdipGetPathPoints(ptr ptr long)
@ stub GdipGetPathPointsI @ stub GdipGetPathPointsI
@ stdcall GdipGetPathTypes(ptr ptr long) @ stdcall GdipGetPathTypes(ptr ptr long)
@ stub GdipGetPathWorldBounds @ stdcall GdipGetPathWorldBounds(ptr ptr ptr ptr)
@ stub GdipGetPathWorldBoundsI @ stub GdipGetPathWorldBoundsI
@ stub GdipGetPenBrushFill @ stub GdipGetPenBrushFill
@ stub GdipGetPenColor @ stub GdipGetPenColor

View File

@ -203,6 +203,58 @@ GpStatus WINGDIPAPI GdipGetPathTypes(GpPath *path, BYTE* types, INT count)
return Ok; return Ok;
} }
/* Windows expands the bounding box to the maximum possible bounding box
* for a given pen. For example, if a line join can extend past the point
* it's joining by x units, the bounding box is extended by x units in every
* direction (even though this is too conservative for most cases). */
GpStatus WINGDIPAPI GdipGetPathWorldBounds(GpPath* path, GpRectF* bounds,
GDIPCONST GpMatrix *matrix, GDIPCONST GpPen *pen)
{
/* extrema[0] is upper left corner of bounding box,
* extrema[1] is lower right corner */
GpPointF extrema[2];
GpPointF * points;
INT count, i;
/* Matrix and pen can be null. */
if(!path || !bounds)
return InvalidParameter;
/* If path is empty just return. */
count = path->pathdata.Count;
if(count == 0){
bounds->X = bounds->Y = bounds->Width = bounds->Height = 0.0;
return Ok;
}
/* FIXME: implement case where pen is non-NULL. */
if(pen)
return NotImplemented;
points = path->pathdata.Points;
extrema[0].X = extrema[1].X = points[0].X;
extrema[0].Y = extrema[1].Y = points[0].Y;
for(i = 1; i < count; i++){
extrema[0].X = min(points[i].X, extrema[0].X);
extrema[0].Y = min(points[i].Y, extrema[0].Y);
extrema[1].X = max(points[i].X, extrema[1].X);
extrema[1].Y = max(points[i].Y, extrema[1].Y);
}
/* If matrix is non-null transform the points. */
if(matrix){
GdipTransformMatrixPoints((GpMatrix*)matrix, extrema, 2);
}
bounds->X = extrema[0].X;
bounds->Y = extrema[0].Y;
bounds->Width = extrema[1].X - extrema[0].X;
bounds->Height = extrema[1].Y - extrema[0].Y;
return Ok;
}
GpStatus WINGDIPAPI GdipGetPointCount(GpPath *path, INT *count) GpStatus WINGDIPAPI GdipGetPointCount(GpPath *path, INT *count)
{ {
if(!path) if(!path)

View File

@ -57,6 +57,8 @@ GpStatus WINGDIPAPI GdipCreatePath(GpFillMode,GpPath**);
GpStatus WINGDIPAPI GdipDeletePath(GpPath*); GpStatus WINGDIPAPI GdipDeletePath(GpPath*);
GpStatus WINGDIPAPI GdipGetPathPoints(GpPath*,GpPointF*,INT); GpStatus WINGDIPAPI GdipGetPathPoints(GpPath*,GpPointF*,INT);
GpStatus WINGDIPAPI GdipGetPathTypes(GpPath*,BYTE*,INT); GpStatus WINGDIPAPI GdipGetPathTypes(GpPath*,BYTE*,INT);
GpStatus WINGDIPAPI GdipGetPathWorldBounds(GpPath*,GpRectF*,GDIPCONST GpMatrix*,
GDIPCONST GpPen*);
GpStatus WINGDIPAPI GdipGetPointCount(GpPath*,INT*); GpStatus WINGDIPAPI GdipGetPointCount(GpPath*,INT*);
GpStatus WINGDIPAPI GdipStartPathFigure(GpPath*); GpStatus WINGDIPAPI GdipStartPathFigure(GpPath*);
GpStatus WINGDIPAPI GdipTransformPath(GpPath*,GpMatrix*); GpStatus WINGDIPAPI GdipTransformPath(GpPath*,GpMatrix*);

View File

@ -46,5 +46,6 @@ typedef PointF GpPointF;
typedef FillMode GpFillMode; typedef FillMode GpFillMode;
typedef PathData GpPathData; typedef PathData GpPathData;
typedef LineCap GpLineCap; typedef LineCap GpLineCap;
typedef RectF GpRectF;
#endif #endif

View File

@ -122,6 +122,16 @@ public:
BYTE* Types; BYTE* Types;
}; };
/* FIXME: missing the methods. */
class RectF
{
public:
REAL X;
REAL Y;
REAL Width;
REAL Height;
};
#else /* end of c++ typedefs */ #else /* end of c++ typedefs */
typedef struct PointF typedef struct PointF
@ -137,6 +147,14 @@ typedef struct PathData
BYTE* Types; BYTE* Types;
} PathData; } PathData;
typedef struct RectF
{
REAL X;
REAL Y;
REAL Width;
REAL Height;
} RectF;
typedef enum Status Status; typedef enum Status Status;
#endif /* end of c typedefs */ #endif /* end of c typedefs */