Hi,@Nicholas Piazza. Welcome Microsoft Q&A. To make the code work, you'll need to add the "Button.bmp" image as a resource in your project. Here's how you could add the "Button.bmp" image as a resource in your project:
Add the image as a resource in your project:
- In Visual Studio, open your project and go to the Solution Explorer.
- Right-click on your project name and select "Properties."
- In the properties window, go to the "Resources" tab.
- Click on the "Add Resource" dropdown and choose "Add Existing File..."
- Browse to the location where you saved the "Button.bmp" image, select it, and click "Open."
Access the image resource in your code:
- Once you've added the "Button.bmp" image as a resource, it will be accessible in your code as a
Bitmapobject. You can use theProperties.Resourcesclass to access the resource and create theBitmap.
private void ConstructFromResourceSaveAsGif(PaintEventArgs e)
{
// Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");
Bitmap bmp1 = Properties.Resources.Button;
bmp1.Save(path + "button.gif",
System.Drawing.Imaging.ImageFormat.Gif);
Bitmap bmp2 = new Bitmap(path + "8.gif");
e.Graphics.DrawImage(bmp1, new Point(10, 10));
e.Graphics.DrawImage(bmp2, new Point(10, 40));
bmp1.Dispose();
bmp2.Dispose();
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.