Link to home
Start Free TrialLog in
Avatar of occr
occr

asked on

How to release resouces used by a PictureBox and still use it

I have a program that uses PictureBox control to display a tiff image. The only property/method i am using for this control is the Handle. I use routines from a proprietary DLL to manipulate the image, basically display and merge text into the tiff image.

The issue i am having is that after about two hundred images have been processed, the program crashes and displays the message, "Screen-compatible bitmap cannot be created. The screen bitmap format cannot be determined."

If I reduce the amount of text that i add to the tiff image by half then i can process almost twice as many (almost 350+) images. Also if i add and use a second PictureBox control and switch to it after processing about 175 images i can process twice as many images in one run.
I think that the resources being used by the PictureBox contol are not being released.

If i use the Dispose method to release resources, i can no longer use the PictureBox control. I get the message "Cannot access a disposed object".

How can i release resources used by the PictureBox control after processing each image and still use it?

Any help is greatly appreciated.  Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of occr
occr

ASKER

You were right i just had to dig into the DLL documentation to fix this issue. It's just that i had never used the PictureBox control before and wanted to be sure thatit's not the culprit. Thank you.
Glad the DLL was well documented!...  =)