System.Drawing.Imaging performance fix in .NET 1.1 SP1
A few months ago I encountered a significant performance problem with System.Drawing.Imaging.
I found that by using the new Method performance was 93x faster (on average) for loading jpegs.
You can download the update here:
Specifically, this update adds a new method to System.Drawing.Imaging:
System.Drawing.Image.FromStream(Stream stream, bool useICM, bool validateImageData)
This is essentially a new signature for an existing method:
System.Drawing.Image.FromStream(Stream stream, bool useICM)
As you can see, validateImageData is a new parameter. Setting it to true is the default behavior that we have today (essentially the same as calling FromStream(Stream stream, bool useICM)).
So I made a change to my application. Before my code looked like this:
using (Image photo = Image.FromFile(this.fileInfo.FullName, true))
{
//do stuff
}
So I changed it to:
using (FileStream fs = new FileStream(this.fileInfo.FullName, FileMode.Open, FileAccess.ReadWrite))
{
using (Image photo = Image.FromStream(fs, true, false))
{
// do stuff
}
}