ImageBuilder can be extended in two ways.
- By writing a subclass of ImageBuilderExtension, and registering it with Config.ImageBuilderExtensions (It is suggested you implement IPlugin also)
- By implementing IEncoder and registering it with Config.ImageEncoders
The primary method. Accepts VirtualFiles, physical paths, Bitmap objects, etc. Extremely flexible. Uses LoadImage to turn 'source' into a bitmap.
void Build(object source, object dest, ResizeSettingsCollection settings);
Lifecycle of Build()
- Calls LoadImage(source) to acquire a source bitmap
- Calls PreAcquireStream
- If destination is a string or stream, acquires an output stream from
- If dest is a stream, calls buildToStream. Otherwise, calls buildToBitmap.
Convenience method for getting a Bitmap result (Wraps above method):
Bitmap Build(object source, ResizeSettingsCollection settings);
Bitmap LoadImage(object source, bool useICM);
- Calls PreLoadImage(ref object source, ref bool useICM)
- Turns a string, VirtualFile, IVirtualBitmapFile, HttpPostedFile, Bitmap, Image, or Stream into a Bitmap and returns it. Attaches any path (if present) to Bitmap.Tag
Calls buildToBitmap, then encodes the result into the specified stream
protected virtual void buildToStream(Bitmap source, Stream dest, ResizeSettingsCollection settings)
Everything channels through here. This is where the science happens.
protected virtual Bitmap buildToBitmap(Bitmap source, ResizeSettingsCollection settings)
Lifecycle of buildToBitmap
- Prepare ImageState instance. All operations occur on an ImageState instance. Populates with sourceBitmap, settings, maxSize, and originalSize
- Runs Process(ImageState)
- Disposes unneeded objects in ImageState and returns the resulting bitmap.