Loading...

Corrupted Image

Discussions about image processing in GdPicture.NET using GdPictureImaging.

Corrupted Image

Postby payne296 » Wed Apr 20, 2011 10:14 pm

Hello all,

I'm having an issue with images occasionally getting corrupted. I'm not sure sure if this is happening in the SaveAsTiff method or the CreateGdPictureImage method (from file), but I've attached a source copy and what returns when it's corrupted. It seems to happen about 1 in every 1000 times I save and load, has anyone seen this before?
Attachments
corrupted.tif
Image after corruption.
source.tif
Image before corruption.
payne296
 
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

Re: Corrupted Image

Postby payne296 » Thu Apr 21, 2011 6:17 pm

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);
   }
}
payne296
 
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm


Return to Image Processing

Who is online

Users browsing this forum: No registered users and 0 guests