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 - How to resolve aspect ratio differences between the requested size and the original image's size.
  • Anchor - Determines where the image will be anchored if there is padding or cropping. The default is "middleCenter".
  • Scale - Controls whether the image is allowed to upscale, downscale, both, or if only the canvas gets to be upscaled.
    • sdfsdf

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