Hi. I am loading images from a database and want to dynamically resize them according to some input.
Code is something like this:
public ActionResult GetImage(string imageID, int? width, int? height, bool constrain)
{
ValidateImageInput(width, height, constrain);
ImageWithMimeType info = LoadFromDatabase(imageID);
if(info == null)
throw new HttpException(404, "Image with that name or id was not found.");
Resize(info.Bytedata, width, height, constrain, info.MimeType);
return File(info.Data, info.MimeType);
}
How would I implement Resize in a way that preserves encoding type etc? I've looked at http://stackoverflow.com/questions/1357257/image-resizing-efficiency-in-c-and-net-3-5 but don't see how it would preserve encoding - since creating a new Bitmap surely isn't encoded?