Displaying a bitmap

G

Guest

I'm trying to draw a bitmap on the screen, but I'd like to embed the bitmap into my assembly so I don't have to include the .BMP file with my executable

Anyone know how to do this? And how do I retrieve it from my resources in memory so I can display it? I figured I could just add a bitmap resource into my project and set the Build Action to "Embedded resource", but doesn't show up on the .resx file, and I can't set its ID. Help

Thanks

Alfredo Diaz.
 
H

Herfried K. Wagner [MVP]

* =?Utf-8?B?QWxmcmVkbyBEaWF6?= said:
I'm trying to draw a bitmap on the screen, but I'd like to embed the
bitmap into my assembly so I don't have to include the .BMP file with my
executable.

Anyone know how to do this? And how do I retrieve it from my
resources in memory so I can display it? I figured I could just add a
bitmap resource into my project and set the Build Action to "Embedded
resource", but doesn't show up on the .resx file, and I can't set its
ID. Help!

Add the image, set its 'Build Action' to 'Embedded Resource', then you
can use this code to load the bitmap:

\\\
Me.picMyPicture.Image = _
New Bitmap( _
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
"<Root namespace>.<File name>" _
) _
)
///
 
K

Ken Tucker [MVP]

Hi,

Add the image to your project. Set it build action to embedded
resource.

Dim img As Image

Dim p As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()

img = Image.FromStream(p.GetManifestResourceStream(Me.GetType, "Water
lilies.jpg"))



Ken
 

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