Resizer Class

Namespace:
Weavy.Core.Imaging
Assembly:
Weavy.Core.dll

Encapsulates an image resizing operation.

public class Resizer
Inheritance:
System.Object → Resizer

Constructors

Resizer() Creates a resizer with Mode=Fit, Format=Auto, Scaling=Down, JpegQuality=90, Opacity = 100, Alignment = MiddleCenter and IgnoreIccProfile=false.
Resizer(String) Creates a resizer by parsing the specified options string.

Properties

Alignment How to anchor the image when padding or cropping, defaults to MiddleCenter.
CopyRect The part of the source image to copy
Destination The Bitmap object the target image is rendered to before encoding.
DestinationSize The size to create the target image
Format The encoding format to use when writing the result to stream.
Height The height constraint
IgnoreIccProfile If true, the ICC profile will be ignored instead of being applied.
JpegQuality The jpeg encoding quality to use (0..100), 90 is the best value and the default. Seriously.
Matte The background color to apply (null for transparency), white will be used if the encoding format is Jpeg and this is unspecified.
Mode The constraint mode, defaults to Fit.
Opacity The opacity value (0..100) to use when when rendering the image, 100 means fully opaque and is the default.
OriginalSize The dimensions of the source image
Scaling Should upscaling be permitted? Defaults to downscaling only.
Source The source bitmap
SourcePath Source path, used for simple output format detection based on filename.
TargetRect Where on the target canvas to render the source image
UnderlyingStream The stream underlying the bitmap (cannot be disposed before the bitmap)
Width The width constraint

Methods

Encode(Stream) Destination is encoded.
Layout() Layout: size and cropping constraints are calculated here
Render() All rendering occurs here; see layout for the math part of things. Neither 'Dest' nor 'Source' are disposed here!
Resize(Bitmap, Resizer.BitmapConsumer, JobOptions) Loads the bitmap from stream, processes, and renders, sending the result Bitmap to the 'consumer' callback for encoding or usage.
Resize(Bitmap, string, JobOptions) Reads from bitmap and writes to the given physical path.
Resize(Stream, Resizer.BitmapConsumer, JobOptions) Loads the bitmap from stream, processes, and renders, sending the result Bitmap to the 'consumer' callback for encoding or usage.
Resize(Stream, Stream, JobOptions) Resizes from one stream to another. Warning, ensure that the first stream you open will be safely closed if the second stream fails to open! This means a using() or try/finally clause.
Resize(Stream, string, JobOptions) Reads from stream and writes to the given physical path.
Resize(string, string, JobOptions) Resizes from one filename to another.

Extension Methods

IsNullOrDefault(T) Gets a value indicating if the specified value has the default value of the generic type.
Serialize(object) Serializes an object, or graph of connected objects, to a byte array.
SerializeToJson(object, Formatting?, JsonSerializerSettings) Serializes an object, or graph of connected objects, to a json string.
IsValid(object) Determines whether the specified object is valid by evaluating each ValidationAttribute instance that is attached to the object type.