I am performing image manipulation on Sitecore.
Given the ID of an image, I want to be able to retrieve it in Bitmap format - I am currently at loss on how to perform such an apparently simple task, and not for lack of searching.
EDIT: I am talking about a Bitmap object (System.Drawing.Bitmap), the reason being that I need to process them using a third-party graphic library (AForge).
I found out eventually; this is the code that will convert an image residing in Sitecore's Media Library in System.Drawing.Bitmap format:
var item = new Sitecore.Context.Database.GetItem(imageId); var mediaItem = Sitecore.Data.Items.MediaItem(item); var image = new System.Drawing.Bitmap(mediaItem.GetMediaStream());