The corruption seems to occur in CreateGdPictureImageFromFile. Like I said, it works 99.9% of the time, but here is the code that has issues.
- Code: Select all
public int GetGdPictureImage()
{
return gdPictureImaging.CreateGdPictureImageFromFile(this.cachePath);
}
I've replaced that code block with the following block, and tested about 100,000 image loads without error. I'm not sure why this would work and the former doesn't, but that currently seems to be the case.
- Code: Select all
public int GetGdPictureImage()
{
using (FileStream fileStream = new FileStream(this.cachePath, FileMode.Open, FileAccess.Read))
{
byte[] bytes = new byte[fileStream.Length];
fileStream.Read(bytes, 0, bytes.Length);
return gdPictureImaging.CreateGdPictureImageFromByteArray(ref bytes);
}
}