Hello,
I'm trying to load different images (icons) into a PictureBox1.Image.
The first image loads just fine, but the second image always returns the
error "Invalid property used."
It doesn't matter what icons are loaded. The first always shows up and any
icons after that give me the error.
Here is the offending code:
The "DestinationPath" variable is the full path and filename of the icon
Private Sub LoadIcon()
Dim FStream As New FileStream(DestinationPath, FileMode.Open)
Try
PictureBox1.Image = System.Drawing.Image.FromStream(FStream)
Catch Err As Exception
MsgBox(Err.Message)
End Try
FStream.Close()
End Sub
Is there something I am forgetting to close or clear? 6 2117
Welcome to MS graphics!!!! (I am not a big fan of .NET graphics).
You are closing your file stream in the subroutine. Once you do that,
the picturebox cannot manipulate the image or even re-draw it.
Since the file must stay open so the picturebox can use it, try
this....
Private Sub LoadIcon()
'set up an image
Dim newimage As System.Drawing.Image
'fill from file
'but the file will stay open !!!!!
newimage = System.Drawing.Image.FromFile(lcl_filename)
'this will close the last file opened
If Not PictureBox1.Image Is Nothing Then
PictureBox1.Image.Dispose()
End If
Try
PictureBox1.Image = newimage
Catch Err As Exception
MsgBox(Err.Message)
End Try
End Sub
Now the file will be opened and locked by the picturebox, but you will
be able to do what you are trying.
HTH
Barry
On Sat, 2 Oct 2004 20:11:08 -0500, "Patrick Dugan"
<pa******@netins.net> wrote: Hello, I'm trying to load different images (icons) into a PictureBox1.Image.
The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error.
Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon Private Sub LoadIcon() Dim FStream As New FileStream(DestinationPath, FileMode.Open) Try PictureBox1.Image = System.Drawing.Image.FromStream(FStream) Catch Err As Exception MsgBox(Err.Message) End Try FStream.Close() End Sub
Is there something I am forgetting to close or clear?
bceggersATcomcastDOTnet
I tried the code but after it loads a few icons it gives me an out-of-memory
error.
I'm really beginning to "love" vb.net right now. Some things that were
simple are now ridiculously hard
and other things are easier.
Do I need to dispose of the newimage after it gets placed into the
Picturebox?
"Barry" <bc******@castcom.com> wrote in message
news:f7********************************@4ax.com... Welcome to MS graphics!!!! (I am not a big fan of .NET graphics).
You are closing your file stream in the subroutine. Once you do that, the picturebox cannot manipulate the image or even re-draw it.
Since the file must stay open so the picturebox can use it, try this....
Private Sub LoadIcon() 'set up an image Dim newimage As System.Drawing.Image 'fill from file 'but the file will stay open !!!!! newimage = System.Drawing.Image.FromFile(lcl_filename) 'this will close the last file opened If Not PictureBox1.Image Is Nothing Then PictureBox1.Image.Dispose() End If
Try PictureBox1.Image = newimage Catch Err As Exception MsgBox(Err.Message) End Try
End Sub
Now the file will be opened and locked by the picturebox, but you will be able to do what you are trying.
HTH Barry On Sat, 2 Oct 2004 20:11:08 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image.
The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error.
Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon Private Sub LoadIcon() Dim FStream As New FileStream(DestinationPath, FileMode.Open) Try PictureBox1.Image = System.Drawing.Image.FromStream(FStream) Catch Err As Exception MsgBox(Err.Message) End Try FStream.Close() End Sub
Is there something I am forgetting to close or clear?
bceggersATcomcastDOTnet
No, don't dispose of newimage. If you try that you will find that the
picturebox can't handle the image.
Is your out of memory error a "GDI+" error or a system error?
How many icons can you load before you get this error? I don't have
any problems with 30+ times into the subroutine.
Barry
On Sun, 3 Oct 2004 10:48:56 -0500, "Patrick Dugan"
<pa******@netins.net> wrote: I tried the code but after it loads a few icons it gives me an out-of-memory error.
I'm really beginning to "love" v b.netrightnow.Somethingsthatwere simple are now ridiculously hard and other things are easier.
Do I need to dispose of the newimage after it gets placed into the Picturebox?
"Barry" <bc******@castcom.com> wrote in message news:f7********************************@4ax.com.. . Welcome to MS graphics!!!! (I am not a big fan of .NET graphics).
You are closing your file stream in the subroutine. Once you do that, the picturebox cannot manipulate the image or even re-draw it.
Since the file must stay open so the picturebox can use it, try this....
Private Sub LoadIcon() 'set up an image Dim newimage As System.Drawing.Image 'fill from file 'but the file will stay open !!!!! newimage = System.Drawing.Image.FromFile(lcl_filename) 'this will close the last file opened If Not PictureBox1.Image Is Nothing Then PictureBox1.Image.Dispose() End If
Try PictureBox1.Image = newimage Catch Err As Exception MsgBox(Err.Message) End Try
End Sub
Now the file will be opened and locked by the picturebox, but you will be able to do what you are trying.
HTH Barry On Sat, 2 Oct 2004 20:11:08 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image.
The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error.
Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon Private Sub LoadIcon() Dim FStream As New FileStream(DestinationPath, FileMode.Open) Try PictureBox1.Image = System.Drawing.Image.FromStream(FStream) Catch Err As Exception MsgBox(Err.Message) End Try FStream.Close() End Sub
Is there something I am forgetting to close or clear?
bceggersATcomcastDOTnet
bceggersATcomcastDOTnet
When I step through it the error occurs on this line:
newimage = System.Drawing.Image.FromFile(DestinationPath)
This is the second time through. How can I tell what type of memory error
it is? I don't see anything in the error
message about GDI just the "Out of memory" text
"Barry" <bc******@castcom.com> wrote in message
news:95********************************@4ax.com... No, don't dispose of newimage. If you try that you will find that the picturebox can't handle the image.
Is your out of memory error a "GDI+" error or a system error?
How many icons can you load before you get this error? I don't have any problems with 30+ times into the subroutine.
Barry
On Sun, 3 Oct 2004 10:48:56 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
I tried the code but after it loads a few icons it gives me an out-of-memory error.
I'm really beginning to "love" v b.netrightnow.Somethingsthatwere simple are now ridiculously hard and other things are easier.
Do I need to dispose of the newimage after it gets placed into the Picturebox?
"Barry" <bc******@castcom.com> wrote in message news:f7********************************@4ax.com. .. Welcome to MS graphics!!!! (I am not a big fan of .NET graphics).
You are closing your file stream in the subroutine. Once you do that, the picturebox cannot manipulate the image or even re-draw it.
Since the file must stay open so the picturebox can use it, try this....
Private Sub LoadIcon() 'set up an image Dim newimage As System.Drawing.Image 'fill from file 'but the file will stay open !!!!! newimage = System.Drawing.Image.FromFile(lcl_filename) 'this will close the last file opened If Not PictureBox1.Image Is Nothing Then PictureBox1.Image.Dispose() End If
Try PictureBox1.Image = newimage Catch Err As Exception MsgBox(Err.Message) End Try
End Sub
Now the file will be opened and locked by the picturebox, but you will be able to do what you are trying.
HTH Barry On Sat, 2 Oct 2004 20:11:08 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image.
The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error.
Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon Private Sub LoadIcon() Dim FStream As New FileStream(DestinationPath, FileMode.Open) Try PictureBox1.Image = System.Drawing.Image.FromStream(FStream) Catch Err As Exception MsgBox(Err.Message) End Try FStream.Close() End Sub
Is there something I am forgetting to close or clear?
bceggersATcomcastDOTnet
bceggersATcomcastDOTnet
Are you sure that the second file is an icon file? What happens if it
goes first (or third)? Can you just load it into the picturebox from
the IDE?
From the help file --
Image.Fromfile - Creates an Image object from the specified file.
<snip>
If the file does not have a valid image format or if GDI+ does not
support the pixel format of the file, this method throws an
OutOfMemoryException exception.
It seems as if the Icon file has something different. What is it?
What is the size, resolution, pallete, etc. ?
On Sun, 3 Oct 2004 15:29:37 -0500, "Patrick Dugan"
<pa******@netins.net> wrote: When I step through it the error occurs on this line:
newimage = System.Drawing.Image.FromFile(DestinationPath)
This is the second time through. How can I tell what type of memory error it is? I don't see anything in the error message about GDI just the "Out of memory" text "Barry" <bc******@castcom.com> wrote in message news:95********************************@4ax.com.. . No, don't dispose of newimage. If you try that you will find that the picturebox can't handle the image.
Is your out of memory error a "GDI+" error or a system error?
How many icons can you load before you get this error? I don't have any problems with 30+ times into the subroutine.
Barry
On Sun, 3 Oct 2004 10:48:56 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
I tried the code but after it loads a few icons it gives me an out-of-memory error.
I'm really beginning to "love" v b.netrightnow.Somethingsthatwere simple are now ridiculously hard and other things are easier.
Do I need to dispose of the newimage after it gets placed into the Picturebox?
"Barry" <bc******@castcom.com> wrote in message news:f7********************************@4ax.com ... Welcome to MS graphics!!!! (I am not a big fan of .NET graphics).
You are closing your file stream in the subroutine. Once you do that, the picturebox cannot manipulate the image or even re-draw it.
Since the file must stay open so the picturebox can use it, try this....
Private Sub LoadIcon() 'set up an image Dim newimage As System.Drawing.Image 'fill from file 'but the file will stay open !!!!! newimage = System.Drawing.Image.FromFile(lcl_filename) 'this will close the last file opened If Not PictureBox1.Image Is Nothing Then PictureBox1.Image.Dispose() End If
Try PictureBox1.Image = newimage Catch Err As Exception MsgBox(Err.Message) End Try
End Sub
Now the file will be opened and locked by the picturebox, but you will be able to do what you are trying.
HTH Barry On Sat, 2 Oct 2004 20:11:08 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
>Hello, > I'm trying to load different images (icons) into a > PictureBox1.Image. > >The first image loads just fine, but the second image always returns the >error "Invalid property used." >It doesn't matter what icons are loaded. The first always shows up and >any >icons after that give me the error. > >Here is the offending code: >The "DestinationPath" variable is the full path and filename of the icon > Private Sub LoadIcon() > Dim FStream As New FileStream(DestinationPath, FileMode.Open) > Try > PictureBox1.Image = System.Drawing.Image.FromStream(FStream) > Catch Err As Exception > MsgBox(Err.Message) > End Try > FStream.Close() > End Sub > > >Is there something I am forgetting to close or clear? > > >
bceggersATcomcastDOTnet
bceggersATcomcastDOTnet
bceggersATcomcastDOTnet
I think you are right. One of the icons looks okay but won't load into the
image. I'll have to consider it bad and if it won't load skip it and move
to the next.
"Barry" <bc******@castcom.com> wrote in message
news:sh********************************@4ax.com... Are you sure that the second file is an icon file? What happens if it goes first (or third)? Can you just load it into the picturebox from the IDE?
From the help file --
Image.Fromfile - Creates an Image object from the specified file. <snip> If the file does not have a valid image format or if GDI+ does not support the pixel format of the file, this method throws an OutOfMemoryException exception.
It seems as if the Icon file has something different. What is it? What is the size, resolution, pallete, etc. ?
On Sun, 3 Oct 2004 15:29:37 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
When I step through it the error occurs on this line:
newimage = System.Drawing.Image.FromFile(DestinationPath)
This is the second time through. How can I tell what type of memory error it is? I don't see anything in the error message about GDI just the "Out of memory" text "Barry" <bc******@castcom.com> wrote in message news:95********************************@4ax.com. .. No, don't dispose of newimage. If you try that you will find that the picturebox can't handle the image.
Is your out of memory error a "GDI+" error or a system error?
How many icons can you load before you get this error? I don't have any problems with 30+ times into the subroutine.
Barry
On Sun, 3 Oct 2004 10:48:56 -0500, "Patrick Dugan" <pa******@netins.net> wrote:
I tried the code but after it loads a few icons it gives me an out-of-memory error.
I'm really beginning to "love" v b.netrightnow.Somethingsthatwere simple are now ridiculously hard and other things are easier.
Do I need to dispose of the newimage after it gets placed into the Picturebox?
"Barry" <bc******@castcom.com> wrote in message news:f7********************************@4ax.co m... > Welcome to MS graphics!!!! (I am not a big fan of .NET graphics). > > You are closing your file stream in the subroutine. Once you do that, > the picturebox cannot manipulate the image or even re-draw it. > > Since the file must stay open so the picturebox can use it, try > this.... > > Private Sub LoadIcon() > 'set up an image > Dim newimage As System.Drawing.Image > 'fill from file > 'but the file will stay open !!!!! > newimage = System.Drawing.Image.FromFile(lcl_filename) > 'this will close the last file opened > If Not PictureBox1.Image Is Nothing Then > PictureBox1.Image.Dispose() > End If > > Try > PictureBox1.Image = newimage > Catch Err As Exception > MsgBox(Err.Message) > End Try > > End Sub > > Now the file will be opened and locked by the picturebox, but you will > be able to do what you are trying. > > HTH > Barry > On Sat, 2 Oct 2004 20:11:08 -0500, "Patrick Dugan" > <pa******@netins.net> wrote: > >>Hello, >> I'm trying to load different images (icons) into a >> PictureBox1.Image. >> >>The first image loads just fine, but the second image always returns >>the >>error "Invalid property used." >>It doesn't matter what icons are loaded. The first always shows up >>and >>any >>icons after that give me the error. >> >>Here is the offending code: >>The "DestinationPath" variable is the full path and filename of the >>icon >> Private Sub LoadIcon() >> Dim FStream As New FileStream(DestinationPath, FileMode.Open) >> Try >> PictureBox1.Image = >> System.Drawing.Image.FromStream(FStream) >> Catch Err As Exception >> MsgBox(Err.Message) >> End Try >> FStream.Close() >> End Sub >> >> >>Is there something I am forgetting to close or clear? >> >> >> > > bceggersATcomcastDOTnet
bceggersATcomcastDOTnet
bceggersATcomcastDOTnet This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: vincent wehren |
last post by:
Hi,
Trying to grasp Py_NewInterpreter()in a simple app embedding Python, I was
wondering why the following gives me an error:
int main() {
PyThreadState *tstate;
Py_Initialize();
|
by: Stephen Poley |
last post by:
Could some kind soul explain the errors and warnings that the W3C CSS
validator generates for page: http://www.atlis.nl/testsite/nl/
Results at: http://tinyurl.com/5pxqx
The error "Invalid...
|
by: Wally |
last post by:
I am trying to display images from an Access 2000 database and I get an error
"Invalid Parameter Used" when I execute the code line
"picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
|
by: cnu |
last post by:
Hi
I have to write images(.gif/.bmp/.jpg/.ico), to db and read them. Uploading
images to db works fine for me. Reading from db to byte is also ok. But,
when I try to display them in my form...
|
by: Simon Harris |
last post by:
I'm trying to access a password protected web service. My code is as
follows:
Dim BS7666 As New bs7666.BS7666 'New instance of my web service
Dim CredCache As CredentialCache = New...
|
by: Arnold |
last post by:
I am having problem loading the image from the database. It gives this error:
"Invalid parameter used."
This is my source code:
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf...
|
by: escristian |
last post by:
Hello.
I'm trying to create an Image so I use something like this:
Image newImage = Image.FromFile(filename);
Now when it's a bmp file and certain .gif files it gives me an
exception that...
|
by: imranabdulaziz |
last post by:
Dear All,
I am using sql2005.
i am writing stored procedure to save various master data . I recognize master by @type (input verible) and assign it to @mst veriable then based on @mst no I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |