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.

Recommended Answers

All 2 Replies

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);

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.