Skip to content

Imaging

theonlylawislove edited this page Feb 18, 2013 · 22 revisions

IImageLayoutBuilder

The layout builder is responsible for building the canvas/image dimensions based on some parameters.

  • Width/Height
  • MaxWidth/MaxHeight
  • Mode
  • Anchor
  • Scale

Based on these values, you will get an ImageLayout object that contains the canvas size and the destination of the image (floating rectangle).

Separating the layout building of the image from the actual re-sizing allows use to reuse this logic on problems such as PDF building.

IImageLayoutBuilder imageLayoutBuilder = Noodle.EngineContext.Resolve<IImageLayoutBuilder>();
var sourceSize = new Size(100, 150);
var resizeSettings = new ResizeSettings("width=200&height=200&mode=fit");
var layout = imageLayoutBuilder.BuildLayout(sourceSize, resizeSettings);

IImageManipulator

The image manipulator will re-size an actual image using the logic contained in the IImageManipulator. The result is a Bitmap object that can be with as you please.

IImageManipulator imageManipulator = Noodle.EngineContext.Resolve<IImageManipulator>();
var resized = imageManipulator.Resize("c:\image.jpg", new ResizeSettings("width=200&height=200&mode=fit"));
Clone this wiki locally