0

It may seem like a simple answer, but how do I pass an image to a bitmaps constructor.
for example:

Bitmap bmp = new Bitmap(########);

what would I put in place of the pound signs If i wanted the default image to be

C://Users/Me/Documents/Visual Studio 2010/Projects/MyProject/Image.jpg

Please help.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Geekitygeek
0

It may seem like a simple answer, but how do I pass an image to a bitmaps constructor.
for example:

Bitmap bmp = new Bitmap(########);

what would I put in place of the pound signs If i wanted the default image to be

C://Users/Me/Documents/Visual Studio 2010/Projects/MyProject/Image.jpg

Please help.

From MSDN:
A bitmap consists of the pixel data for a graphics image and its attributes. There are many standard formats for saving a bitmap to a file. GDI+ supports the following file formats: BMP, GIF, EXIF, JPG, PNG and TIFF.

// Retrieve the image.
    myImage = new Bitmap(@"<put your path here>", true);

Edited by Zinderin: n/a

0

I would generally advise against using literal file paths (eg C:/Users/You/MyDocuments/etc) because you can't guarantee the file structure on every machien that runs your code.
Either add the image as an embedded resource and access it from there or add it to your project as content so that it is in the same directory as your executable and you can access it by name.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.