Avoid using System.Drawing directly at all costs - it is fraught with memory leaks, concurrency issues, and encoding bugs. ImageResizer handles and avoids these for you, and offers a Watermarking plugin as well as SampleOverlay sample plugins to show you how to safely create your own if Watermark can't support your needs.
If, despite my warning, you want to get a Bitmap result, you can pass typeof(Bitmap)
as the 'destination' parameter to ImageJob, and access the Bitmap instance from the .Result
property.
Other consequences:
- The Bitmap instance will not be disposed reliably unless you dispose it within a
finally(){}
block (use a temporary variable to cross the scope boundary). - ImageResizer will not help you with encoding the result. If you call .Save(), you will get gigantic jpeg files, and no 8-bit PNG or animated gif support.
- You will not be able to take advantage of any other pipelines (WIC, FreeImage, etc). Most of our future development will be on better pipelines than GDI+/System.Drawing.