How to load a Bitmap/Gif at runtime?

B

Boris Nienke

Hi,

i had the plan to load a black/white bitmap (or a gif) at runtime into a
picturebox-control. Then i like to draw on it (i can draw on it with
mouse-down/-move/-up events - works OK)

but there's no "Loadbitmap" or "LoadFromFile" or something for picturebox
or bitmap object...

So, how can i load and display such bitmap? After loading the b/w-bitmap i
like to draw in color - so the picturebox should have a high-color-format!

thanks
Boris
 
E

Ed Kaim [MSFT]

The bitmap constructor takes a file path as a string.

Once you have the bitmap loaded, you can use Graphics.FromBitmap to get a
graphics object to party on the image.
 
P

Peter Foot [MVP]

Use the Bitmap constructor:-

[C#]
Bitmap mybitmap = new Bitmap("\\somefile.gif");
pictureBox1.Image = mybitmap;

[VB]
Dim mybitmap As New Bitmap("\somefile.gif")
PictureBox1.Image = mybitmap

Then you can draw to the bitmap using Graphics.FromBitmap(mybitmap) to
obtain a graphics object for the bitmap and then call drawing functions on
this

Peter
 
B

Boris Nienke

Thank you Ed and Peter!

sometimes the help-files confuses me more then they help me :-S ... i
should have seen this one.

Boris
 

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