How to load a Bitmap/Gif at runtime?

  • Thread starter Thread starter Boris Nienke
  • Start date Start date
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
 
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.
 
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
 
Thank you Ed and Peter!

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

Boris
 
Back
Top