Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Saving RasterImages to SQL 2005
Started by jigar at 11-08-2007 12:44. Topic has 19 replies.

Print Search « Previous Thread Next Thread »
  11-08-2007, 12:44
jigar is not online. Last active: 7/24/2008 12:12:53 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 343
Re: Saving RasterImages to SQL 2005
Reply Quote
It's possible that the RasterImage is being locked for some reason.  Try to call the Release() method of the raster image object right before you call the save method, and see what it does.  You can comment out the resize command for the test.  One more thing to check would be the BitsPerPixel value before and after the Release() call, to see if it's being modified.  Also you can try locking the object for exclusive memory access by calling the Access() method and then immediately call Release(), so it just locks and unlocks the memory access for it.

If somehow the object gets locked and you try to call Access(), it should throw an error at that line, which means we have our answer, that somewhere it's being locked.  By the way, are you running this in a multi-threaded application or on a multi-core CPU?

I'm still going to ponder over this to see if there could be any other possibilities.

LEADTOOLS Technical Support
   Report 
  11-11-2007, 15:22
mbsiehs is not online. Last active: 6/24/2008 8:44:40 PM mbsiehs

Top 50 Posts
Joined on 09-27-2007
Posts 32
Re: Saving RasterImages to SQL 2005
Reply Quote
I ran the Release() test three successful times, but on the fourth time I got the "Attempted to..." exception.  I also tried the Access()/Release() combination and I still got the same exception.  No new information there.

But as I was testing I thought of a third way that I am handling the high resolution and low resolution images differently.  Recall that highResolutionImage is a copy of the original image in all its glory (size, etc.) whereas lowResolutionImage is just one sized down so that information retrieval over the network is minimized whenever possible.  The difference is that I obtain highResolutionImage from RasterOpenDialog whereas lowResolutionImage is created from highResolutionImage via RasterImage's copy constructor.  Better said, highResolutionImage is meerly a pointer to RasterOpenDialog.OpenFileData[0].Image property with MultiSelect set to false.

From that information, I decided not to use the Image property directly, but rather to create a new RasterImage with it via the RasterImage copy constructor.  I have run 20 tests with no exception being thrown (usually I get the exception after 4-8 tries).  We have an outstanding QA department and I'll get them started on it Monday if they're available, but I feel comfortable that this gives us more information.  Incidentally, this fix is the same as one of my previous band-aids where I was calling RasterCodec.Save() and using the copy constructor as the image to save (duplicating RasterOpenDialog's image).  My ResizeCommand band-aid fix effectively did the same thing since resizing is non-destructive.  The only flaw with this hypothesis is that the sample applications that save to a file behaved just fine.

If this is a sound theory, the net effect for me is that I have to generate another image, which is less than ideal but far more stable.  The cost is one of time since the garbage collector will get rid of RasterOpenDialog's RasterImage.

I am working on a multi-threaded application although I don't yet spin off any threads for any imaging functionality.  I'm sure that will come, but nothing yet.  I'm also on an old-fashioned (ha) single core.

Thanks again for your help.
Matt

   Report 
  11-12-2007, 9:19
jigar is not online. Last active: 7/24/2008 12:12:53 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 343
Re: Saving RasterImages to SQL 2005
Reply Quote
Hi Matt,

It makes sense that the reference to the RasterOpenDialog may be getting garbage collected after a certain amount of time, and causing the error to be thrown.  Instead of using the copy constructor, just do "RasterImage newImage = RasterOpenDialog.OpenFileData[0].Image.CloneAll()."  The CloneAll() method returns an exact copy of the object.  See if that makes it simpler and/or faster than the copy constructor.

LEADTOOLS Technical Support
   Report 
  11-12-2007, 11:17
mbsiehs is not online. Last active: 6/24/2008 8:44:40 PM mbsiehs

Top 50 Posts
Joined on 09-27-2007
Posts 32
Re: Saving RasterImages to SQL 2005
Reply Quote
Jigar,

That's interesting -- I thought the garbage collector would not try to destroy anything if there was a reference pointing to it and the RasterImage object RasterOpenDialog.OpenFileData[0].Image did have a reference to it (highResolutionImage) even after the RasterOpenDialog gets destroyed.  I wonder if Dispose() is manually being called on the RasterImage when the RasterOpenDialog is being disposed of -- that would certainly cause the garbage collector to destroy it regardless of whether highResolutionImage refered to it or not.

Nevertheless, I'll consider this one solved.  Thanks so much for the time you have spent with me working through this.  You've gone above and beyond on this one.

Matt

   Report 
  11-12-2007, 11:30
jigar is not online. Last active: 7/24/2008 12:12:53 PM jigar



Top 10 Posts
Joined on 08-22-2007
Posts 343
Re: Saving RasterImages to SQL 2005
Reply Quote
You're welcome.

LEADTOOLS Technical Support
   Report 
Post
 Page 2 of 2 (20 items) « 1 2
LEAD Support Fo... » Developer » Database » Saving RasterImages to SQL 2005

Powered by Community Server, by Telligent Systems