I can't figure out why i should keep stream opened while i'm using Bitmap
or Image
.
I try to close the stream and use my Image several ways and everything fine.
The question is in what cases i can get exception if continue close the stream after initialization Image
object?
The Image
class will not read in the whole image upon creation through either Image.FromFile
or Image.FromStream
, but instead only read enough to respond to basic queries such as size and pixel format.
Only if you attempt to access the pixels in any way (usually by drawing the image on-screen), does it read the image data.
This lazy nature means that it needs access to the underlying stream (or file) when it needs to later on in its life.