ImageResizer
3.4.0
|
Defines a collection of utility functions for manipulating polygons. These functions may be (re)moved in future releases; be prepared. More...
Public Member Functions | |
delegate object | ForEachFunction (object o) |
Static Public Member Functions | |
static PointF[] | RoundPoints (PointF[] a) |
Rounds the elements of the specified array [not used] More... | |
static PointF[,] | RoundPoints (PointF[,] a) |
Rounds the elements of the specified array [not used] More... | |
static void | ForEach (Array a, ForEachFunction func) |
Modifies the specified array by applying the specified function to each element. More... | |
static PointF[] | RotatePoly (PointF[] poly, double degrees) |
Rotates the specified polygon (or set of points) around the origin. More... | |
static PointF[] | RotatePoly (PointF[] poly, double degrees, PointF origin) |
Rotates the specified polygon (or set of points) around the origin. More... | |
static PointF[] | ScalePoints (PointF[] poly, double xfactor, double yfactor, PointF origin) |
static PointF | ScalePoint (PointF point, double xfactor, double yfactor, PointF origin) |
static PointF[] | ToPoly (RectangleF rect) |
Returns a clockwise array of points on the rectangle. Point 0 is top-left. More... | |
static PointF[] | NormalizePoly (PointF[] poly) |
Moves the polygon so that the upper-left corner of its bounding box is located at 0,0. More... | |
static PointF | RotateVector (PointF v, double radians) |
Rotates the specified point around the origin. More... | |
static PointF | RotateVector (PointF v, double radians, PointF origin) |
static PointF | ChangeMagnitude (PointF v, float length) |
Returns a modified version of the specified vector with the desired length. More... | |
static RectangleF | GetBoundingBox (PointF[] points) |
Returns a bounding box for the specified set of points. More... | |
static RectangleF | GetBoundingBox (double[] flattenedPoints) |
Returns a bounding box for the specified set of points. Odd points are Y values, even points are X values More... | |
static PointF[] | MovePoly (PointF[] points, PointF offset) |
Returns a modified version of the array, with each element being offset by the specified amount. More... | |
static Boolean | ArraysEqual (PointF[] a1, PointF[] a2) |
Returns true if the member elements of the specified arrays match, and the arrays are of the same length. More... | |
static PointF[] | getParallelogram (PointF[] quad) |
Moves element 4 to spot 3 and truncates to 3 elements. For compatiblity with Graphics.DrawImage More... | |
static SizeF | getParallelogramSize (PointF[] p) |
Determines the width and height of the paralellogram. More... | |
static PointF[] | GetSubArray (PointF[,] array, int index) |
Grabs a single-dimension array from a 2 dimensional array, using the specified primary index. More... | |
static Brush | GenerateRadialBrush (Color inner, Color outer, PointF pt, float width) |
Approximates a radial brush using a high-rez PathGradientBrush. More... | |
static SizeF | ScaleInside (SizeF inner, SizeF bounding) |
Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Upscales and downscales. More... | |
static SizeF | ScaleOutside (SizeF innerBounds, SizeF outer) |
Scales 'outer' to be equal or larger than 'innerBounds' while maintaining aspect ratio. Upscales and downscales. More... | |
static SizeF | DownScaleInside (SizeF inner, SizeF bounding) |
Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Only downscales. More... | |
static bool | FitsInside (SizeF inner, SizeF outer) |
Returns true if 'inner' fits inside or equals 'outer' More... | |
static 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. More... | |
static PointF[,] | GetCorners (PointF[] poly, float[] 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. More... | |
static 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. More... | |
static 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 More... | |
static PointF[] | InflatePoly (PointF[] poly, float[] offsets) |
Expands all sides on the specified polygon by the specified offsets. Assumes the polygon is concave. Returns a new polygon. More... | |
static 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' More... | |
static RectangleF | CenterInside (SizeF size, RectangleF bounds) |
Creates a rectangle of size 'size' with a center matching that of bounds. More... | |
static Rectangle | ToRectangle (RectangleF r) |
Rounds a floating-point rectangle to an integer rectangle using System.Round More... | |
static Size | RoundPoints (SizeF sizeF) |
static 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'. More... | |
static 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'. More... | |
static PointF | Average (PointF a, PointF b) |
Returns a point equidistant beweteen A and B More... | |
static 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 More... | |
static double | GetShortestPair (PointF[] poly) |
Returns the length of the shortest line segment in the given polygon. More... | |
static double | Dist (PointF a, PointF b) |
Returns the distance between two points More... | |
static double | NormalizeTo90Intervals (double d) |
Normalizes the given angle to a positive multiple of 90 degrees between 0 and 270. More... | |
static RotateFlipType | CombineFlipAndRotate (RotateFlipType flip, double angle) |
static 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 More... | |
static 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. More... | |
static RectangleF | ClipRectangle (RectangleF box, RectangleF bounds) |
Returns 'box' clipped to be within 'bounds' More... | |
static RectangleF | ExpandTo (RectangleF box, SizeF copySize) |
Expands the given rectangle to be the given size while keeping it centered. More... | |
static RectangleF | ScaleRect (RectangleF rect, double ExpandX, double ExpandY) |
Expands the given rectangle using the specified scale multipliers, leaving it centered More... | |
Defines a collection of utility functions for manipulating polygons. These functions may be (re)moved in future releases; be prepared.
Definition at line 13 of file PolygonMath.cs.
|
inlinestatic |
Aligns the specified rectangle object with its reference ('container') rectangle using the specified alignment. The container can be smaller than 'obj'.
obj | |
container | |
align |
Definition at line 598 of file PolygonMath.cs.
|
inlinestatic |
Aligns the specified polygon with its container (reference) polygon using the specified alignment. The container can be smaller than 'obj'.
obj | |
container | |
align |
Definition at line 621 of file PolygonMath.cs.
|
inlinestatic |
Returns true if the member elements of the specified arrays match, and the arrays are of the same length.
a1 | |
a2 |
Definition at line 275 of file PolygonMath.cs.
Referenced by ImageResizer.ImageBuilder.RenderBackground().
|
inlinestatic |
Returns a point equidistant beweteen A and B
a | |
b |
Definition at line 633 of file PolygonMath.cs.
|
inlinestatic |
Moves 'inner' so that the center of its bounding box equals the center of the bounding box of 'outer'
inner | |
outer |
Definition at line 557 of file PolygonMath.cs.
|
inlinestatic |
Creates a rectangle of size 'size' with a center matching that of bounds.
Definition at line 571 of file PolygonMath.cs.
|
inlinestatic |
Returns a modified version of the specified vector with the desired length.
v | |
length |
Definition at line 205 of file PolygonMath.cs.
|
inlinestatic |
Returns 'box' clipped to be within 'bounds'
box | |
bounds |
Definition at line 795 of file PolygonMath.cs.
|
inlinestatic |
Combines the given flipping info and rotation angle into a RotateFlipType value. Rotation angle will snap to nearest 90-degree multiple
flip | |
angle |
Definition at line 706 of file PolygonMath.cs.
|
inlinestatic |
Returns the distance between two points
pointF | |
pointF_2 |
Definition at line 669 of file PolygonMath.cs.
|
inlinestatic |
Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Only downscales.
inner | |
bounding |
Definition at line 408 of file PolygonMath.cs.
|
inlinestatic |
Expands the given rectangle to be the given size while keeping it centered.
box | |
copySize |
Definition at line 810 of file PolygonMath.cs.
|
inlinestatic |
Returns true if 'inner' fits inside or equals 'outer'
inner | |
outer |
Definition at line 420 of file PolygonMath.cs.
Referenced by ImageResizer.Plugins.CropAround.CropAroundPlugin.LayoutImage(), and ImageResizer.ImageBuilder.LayoutImage().
|
inlinestatic |
Modifies the specified array by applying the specified function to each element.
a | |
func | object delegate(object o){} |
Definition at line 57 of file PolygonMath.cs.
|
inlinestatic |
Approximates a radial brush using a high-rez PathGradientBrush.
inner | |
outer | |
pt | |
width |
Definition at line 334 of file PolygonMath.cs.
|
inlinestatic |
Returns a bounding box for the specified set of points.
points |
Definition at line 218 of file PolygonMath.cs.
Referenced by ImageResizer.Util.PolygonMath.AlignWith(), ImageResizer.Plugins.Watermark.Layer.CalculateLayerCoordinates(), and ImageResizer.Plugins.Basic.Trial.PreFlushChanges().
|
inlinestatic |
Returns a bounding box for the specified set of points. Odd points are Y values, even points are X values
points |
Definition at line 238 of file PolygonMath.cs.
|
inlinestatic |
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
poly | |
width |
Definition at line 436 of file PolygonMath.cs.
|
inlinestatic |
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].
poly | |
widths |
Definition at line 456 of file PolygonMath.cs.
|
inlinestatic |
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.
cropValues | An array of 4 elements defining x1, y1, x2, and y2 of the cropping rectangle |
xunits | The width x1 and x2 are relative to |
yunits | The height y1 and y2 are relative to |
imageSize | The size of the uncropped image |
Definition at line 738 of file PolygonMath.cs.
|
inlinestatic |
Moves element 4 to spot 3 and truncates to 3 elements. For compatiblity with Graphics.DrawImage
quad |
Definition at line 292 of file PolygonMath.cs.
|
inlinestatic |
Determines the width and height of the paralellogram.
p |
Definition at line 306 of file PolygonMath.cs.
|
inlinestatic |
Returns the length of the shortest line segment in the given polygon.
Definition at line 652 of file PolygonMath.cs.
|
inlinestatic |
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.
poly | |
width |
Definition at line 500 of file PolygonMath.cs.
|
inlinestatic |
Grabs a single-dimension array from a 2 dimensional array, using the specified primary index.
array | |
index |
Definition at line 319 of file PolygonMath.cs.
|
inlinestatic |
Expands all sides on the specified polygon by the specified offset. Assumes the polygon is concave. Returns a new polygon
poly | |
offset |
Definition at line 522 of file PolygonMath.cs.
Referenced by ImageResizer.Resizing.LayoutBuilder.AddRing().
|
inlinestatic |
Expands all sides on the specified polygon by the specified offsets. Assumes the polygon is concave. Returns a new polygon.
poly | |
offsets | An array the same size as poly[], with the distances to expand the edges. Edges are between i and i+1 |
Definition at line 540 of file PolygonMath.cs.
|
inlinestatic |
Verifies that the specified 4 points are not rotated - that each point shares either the x or y coordinate with the previous point
Definition at line 640 of file PolygonMath.cs.
|
inlinestatic |
Returns a modified version of the array, with each element being offset by the specified amount.
points | |
offset |
Definition at line 258 of file PolygonMath.cs.
|
inlinestatic |
Moves the polygon so that the upper-left corner of its bounding box is located at 0,0.
poly |
Definition at line 151 of file PolygonMath.cs.
|
inlinestatic |
Normalizes the given angle to a positive multiple of 90 degrees between 0 and 270.
d |
Definition at line 678 of file PolygonMath.cs.
|
inlinestatic |
Rotates the specified polygon (or set of points) around the origin.
poly | |
degrees |
Definition at line 98 of file PolygonMath.cs.
|
inlinestatic |
Rotates the specified polygon (or set of points) around the origin.
poly | |
degrees | |
origin |
Definition at line 113 of file PolygonMath.cs.
|
inlinestatic |
Rotates the specified point around the origin.
v | |
radians |
Definition at line 162 of file PolygonMath.cs.
|
inlinestatic |
Rotates the specified point around the specified origin.
v | |
radians | |
origin |
Definition at line 183 of file PolygonMath.cs.
|
inlinestatic |
Rounds the elements of the specified array [not used]
a |
Definition at line 20 of file PolygonMath.cs.
Referenced by ImageResizer.ImageBuilder.EndLayout().
|
inlinestatic |
Rounds the elements of the specified array [not used]
a |
Definition at line 37 of file PolygonMath.cs.
|
inlinestatic |
Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Upscales and downscales.
inner | |
bounding |
Definition at line 364 of file PolygonMath.cs.
|
inlinestatic |
Scales 'outer' to be equal or larger than 'innerBounds' while maintaining aspect ratio. Upscales and downscales.
innerBounds | |
outer |
Definition at line 387 of file PolygonMath.cs.
Referenced by ImageResizer.Plugins.CropAround.CropAroundPlugin.LayoutImage().
|
inlinestatic |
Expands the given rectangle using the specified scale multipliers, leaving it centered
rect | |
ExpandX | |
ExpandY |
Definition at line 823 of file PolygonMath.cs.
Referenced by ImageResizer.Plugins.Faces.FaceDetection.DetectFeatures().
|
inlinestatic |
Returns a clockwise array of points on the rectangle. Point 0 is top-left.
rect |
Definition at line 137 of file PolygonMath.cs.
|
inlinestatic |
Rounds a floating-point rectangle to an integer rectangle using System.Round
r |
Definition at line 581 of file PolygonMath.cs.