Image Resizer : API Documentation

Type PolygonMath

Namespace ImageResizer.Util

Public static methods

PointF[] AlignWith(PointF[] obj, PointF[] container, ContentAlignment align)

Aligns the specified polygon with its container (reference) polygon using the specified alignment. The container can be smaller than 'obj'.

RectangleF AlignWith(RectangleF obj, RectangleF container, ContentAlignment align)

Aligns the specified rectangle object with its reference ('container') rectangle using the specified alignment. The container can be smaller than 'obj'.

bool ArraysEqual(PointF[] a1, PointF[] a2)

Returns true if the member elements of the specified arrays match, and the arrays are of the same length.

PointF Average(PointF a, PointF b)

Returns a point equidistant beweteen A and B

RectangleF CenterInside(SizeF size, RectangleF bounds)

Creates a rectangle of size 'size' with a center matching that of bounds.

PointF[] CenterInside(PointF[] inner, PointF[] outer)

Moves 'inner' so that the center of its bounding box equals the center of the bounding box of 'outer'

PointF ChangeMagnitude(PointF v, float length)

Returns a modified version of the specified vector with the desired length.

RectangleF ClipRectangle(RectangleF box, RectangleF bounds)

Returns 'box' clipped to be within 'bounds'

RotateFlipType CombineFlipAndRotate(RotateFlipType flip, double angle)

RotateFlipType CombineFlipAndRotate(FlipMode flip, double angle)

Combines the given flipping info and rotation angle into a RotateFlipType value. Rotation angle will snap to nearest 90-degree multiple

double Dist(PointF a, PointF b)

Returns the distance between two points

SizeF DownScaleInside(SizeF inner, SizeF bounding)

Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Only downscales.

RectangleF ExpandTo(RectangleF box, SizeF copySize)

Expands the given rectangle to be the given size while keeping it centered.

bool FitsInside(SizeF inner, SizeF outer)

Returns true if 'inner' fits inside or equals 'outer'

void ForEach(Array a, ForEachFunction func)

Brush GenerateRadialBrush(Color inner, Color outer, PointF pt, float width)

Approximates a radial brush using a high-rez PathGradientBrush.

RectangleF GetBoundingBox(PointF[] points)

Returns a bounding box for the specified set of points.

RectangleF GetBoundingBox(Double[] flattenedPoints)

Returns a bounding box for the specified set of points. Odd points are Y values, even points are X values

PointF[,] GetCorners(PointF[] poly, Single[] widths)

Returns an array of parallelograms. These parallelgrams are the 'corners' outside each vertex in 'poly'. The adjacent edges are perpendicular to 'poly'. Point 1 of each parallelogram will match the respective point in 'poly' Points are clockwise. Each float in widths[] corresponds to the point in poly[]. This is the distance to go perpendicularly from the line beween poly[i] and poly[i +1].

PointF[,] GetCorners(PointF[] poly, float width)

Returns an array of parallelograms. These parallelgrams are the 'corners' outside each vertex in 'poly'. The adjacent edges are perpendicular to 'poly'. Point 1 of each parallelogram will match the respective point in 'poly' Points are clockwise. TODO - some rounding issues going on, not exact numbers here

RectangleF GetCroppingRectangle(Double[] cropValues, double xunits, double yunits, SizeF imageSize)

Used for converting custom crop rectangle coordinates into a valid cropping rectangle. Positive values are relative to 0,0, negative values relative to width, height. X2 and Y2 values of 0 become width and height respectively.
Parameters
Double[] cropValues
An array of 4 elements defining x1, y1, x2, and y2 of the cropping rectangle
double xunits
The width x1 and x2 are relative to
double yunits
The height y1 and y2 are relative to
SizeF imageSize
The size of the uncropped image

PointF[] getParallelogram(PointF[] quad)

Moves element 4 to spot 3 and truncates to 3 elements. For compatiblity with Graphics.DrawImage

SizeF getParallelogramSize(PointF[] p)

Determines the width and height of the paralellogram.

double GetShortestPair(PointF[] poly)

Returns the length of the shortest line segment in the given polygon.

PointF[,] GetSides(PointF[] poly, float width)

Returns an array of parallelograms. These parallelgrams are the 'sides' bounding the polygon. Points are clockwise. Point 1 is the top-left outer point, point 2 the top-right, point 3 the bottom-right, and point 4 the bottom-left.

PointF[] GetSubArray(PointF[,] array, int index)

PointF[] InflatePoly(PointF[] poly, Single[] offsets)

Expands all sides on the specified polygon by the specified offsets. Assumes the polygon is concave. Returns a new polygon.
Parameters
PointF[] poly
Single[] offsets
An array the same size as poly[], with the distances to expand the edges. Edges are between i and i+1

PointF[] InflatePoly(PointF[] poly, float offset)

Expands all sides on the specified polygon by the specified offset. Assumes the polygon is concave. Returns a new polygon

bool IsUnrotated(PointF[] a)

Verifies that the specified 4 points are not rotated - that each point shares either the x or y coordinate with the previous point

PointF[] MovePoly(PointF[] points, PointF offset)

Returns a modified version of the array, with each element being offset by the specified amount.

PointF[] NormalizePoly(PointF[] poly)

Moves the polygon so that the upper-left corner of its bounding box is located at 0,0.

double NormalizeTo90Intervals(double d)

Normalizes the given angle to a positive multiple of 90 degrees between 0 and 270.

PointF[] RotatePoly(PointF[] poly, double degrees)

Rotates the specified polygon (or set of points) around the origin.

PointF[] RotatePoly(PointF[] poly, double degrees, PointF origin)

Rotates the specified polygon (or set of points) around the origin.

PointF RotateVector(PointF v, double radians)

Rotates the specified point around the origin.

PointF RotateVector(PointF v, double radians, PointF origin)

Rotates the specified point around the specified origin.

PointF[] RoundPoints(PointF[] a)

Rounds the elements of the specified array [not used]

PointF[,] RoundPoints(PointF[,] a)

Size RoundPoints(SizeF sizeF)

SizeF ScaleInside(SizeF inner, SizeF bounding)

Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Upscales and downscales.

SizeF ScaleOutside(SizeF innerBounds, SizeF outer)

Scales 'outer' to be equal or larger than 'innerBounds' while maintaining aspect ratio. Upscales and downscales.

PointF ScalePoint(PointF point, double xfactor, double yfactor, PointF origin)

PointF[] ScalePoints(PointF[] poly, double xfactor, double yfactor, PointF origin)

RectangleF ScaleRect(RectangleF rect, double ExpandX, double ExpandY)

Expands the given rectangle using the specified scale multipliers, leaving it centered

PointF[] ToPoly(RectangleF rect)

Returns a clockwise array of points on the rectangle. Point 0 is top-left.

Rectangle ToRectangle(RectangleF r)

Rounds a floating-point rectangle to an integer rectangle using System.Round