Load Image

B

Bob

Hi,

I have a pictureBox.
What is the most efficient way to load an image (png) : FromFile or
FromStream ?
The picture Box is set to Visible = True or Visible = False at the run time.
For the moment i use FromFile, but sometimes, i have an error saying that
the file is all ready in use (can happen or not, and never at the same
moment...)
If i use FromStream, and if i set the Enabled property to false, if another
window is moved on the pictureBox, i have a memory Overflow...

Thanks !
 
V

VJ

When you get FromFile, the file is locked, so you need to dispose the
picturebox or set it to null... when you no longer use the picturebox or
wish to change it.

Similary FromStream, you have to flush and close the stream, when not
needed...

VJ
 
B

Bob

Ok, but i only do the FromFile once, in the constructor.
After, like with a timer, i have my picturebox set to visible = false or
true, just like a blinking if you want.
Then, after a couple of minutes of blinking, i have the "already in use"
message (and the gif loaded in the picturebox is replaced with a red cross
with blank background..)

Do i have to do a FromFile then a Dispose instead of a Visible = true/false
?

Thanks.
 
V

VJ

can you post a sample outline of your code, that describes or can reproduce
the problem?

VJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top