GIFs as Embedded Resources 
Author Message
 GIFs as Embedded Resources

Greetings!

I have the following code to use icons from embedded resources that works:

Dim st As System.IO.Stream
Dim a As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()
st = a.GetManifestResourceStream("TimeKeeper.timer_on.ico")
icnOn = New System.Drawing.Icon(st)

What I need to do now is to embed a GIF image as an embedded resource so I
can put it on a form, but the same premise no longer works:

Dim a As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()
Dim st As System.IO.Stream
st = a.GetManifestResourceStream("TimeKeeper.Plain-Logo.gif")
picLogo.Image = System.Drawing.Image(st)

I get an error on the System.Drawing.Image part of the last line that says
"'Image' is a type in 'Drawing' and cannot be used as an expression."

I'm trying to put the gif into a picture box on my form. Should I be using
some other kind of control other than a picture box or something?

Thanks!
Russ



Tue, 21 Sep 2004 05:04:25 GMT  
 GIFs as Embedded Resources
Try using a System.Drawing.Bitmap object instead of a System.Drawing.Image
type:

Dim a As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()
Dim st As System.IO.Stream
st = a.GetManifestResourceStream("TimeKeeper.Plain-Logo.gif")
picLogo.Image = new System.Drawing.BitMap(st)

Andy


Quote:
> Greetings!

> I have the following code to use icons from embedded resources that works:

> Dim st As System.IO.Stream
> Dim a As System.Reflection.Assembly =
> System.Reflection.Assembly.GetExecutingAssembly()
> st = a.GetManifestResourceStream("TimeKeeper.timer_on.ico")
> icnOn = New System.Drawing.Icon(st)

> What I need to do now is to embed a GIF image as an embedded resource so I
> can put it on a form, but the same premise no longer works:

> Dim a As System.Reflection.Assembly =
> System.Reflection.Assembly.GetExecutingAssembly()
> Dim st As System.IO.Stream
> st = a.GetManifestResourceStream("TimeKeeper.Plain-Logo.gif")
> picLogo.Image = System.Drawing.Image(st)

> I get an error on the System.Drawing.Image part of the last line that says
> "'Image' is a type in 'Drawing' and cannot be used as an expression."

> I'm trying to put the gif into a picture box on my form. Should I be using
> some other kind of control other than a picture box or something?

> Thanks!
> Russ



Tue, 21 Sep 2004 06:29:44 GMT  
 GIFs as Embedded Resources
Yeah, that was it.

Stupid me, thinking that Bitmap meant a BMP file.... ;)

Thanks for the help!


Quote:
> Try using a System.Drawing.Bitmap object instead of a System.Drawing.Image
> type:

> Dim a As System.Reflection.Assembly =
> System.Reflection.Assembly.GetExecutingAssembly()
> Dim st As System.IO.Stream
> st = a.GetManifestResourceStream("TimeKeeper.Plain-Logo.gif")
> picLogo.Image = new System.Drawing.BitMap(st)

> Andy



> > Greetings!

> > I have the following code to use icons from embedded resources that
works:

> > Dim st As System.IO.Stream
> > Dim a As System.Reflection.Assembly =
> > System.Reflection.Assembly.GetExecutingAssembly()
> > st = a.GetManifestResourceStream("TimeKeeper.timer_on.ico")
> > icnOn = New System.Drawing.Icon(st)

> > What I need to do now is to embed a GIF image as an embedded resource so
I
> > can put it on a form, but the same premise no longer works:

> > Dim a As System.Reflection.Assembly =
> > System.Reflection.Assembly.GetExecutingAssembly()
> > Dim st As System.IO.Stream
> > st = a.GetManifestResourceStream("TimeKeeper.Plain-Logo.gif")
> > picLogo.Image = System.Drawing.Image(st)

> > I get an error on the System.Drawing.Image part of the last line that
says
> > "'Image' is a type in 'Drawing' and cannot be used as an expression."

> > I'm trying to put the gif into a picture box on my form. Should I be
using
> > some other kind of control other than a picture box or something?

> > Thanks!
> > Russ



Wed, 22 Sep 2004 05:37:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Embedding shockwave movies and animated gifs in vb projects

2. Embedding jpgs,gifs,etc

3. Playing WAV from Embedded Resource

4. embedding resources

5. Help with loading embedded resources

6. Reference embedded resource

7. How to access embedded resources?

8. Embed sounds into VB resources

9. Embedded Resource (.ico or .bmp) and ListView

10. ImageList and an embedded resource file.

11. Using "embedded resources"

12. Web control using embedded resource

 

 
Powered by phpBB® Forum Software