Bitmap(Type, String)
Initialized from the specified resource Bitmap new instance of the class.
public Bitmap (Type type, string resource);
parameter
- type
- Type
Used to extract the resource class.
- resource
- String
Name of the resource.
Examples
The following sample code shows how the type bitmap configuration, and how to use the Save method. To run this example, paste the code into a Windows Form. Handle the form's Paint event and call the ConstructFromResourceSaveAsGif
method, and e
as PaintEventArgs
private void ConstructFromResourceSaveAsGif(PaintEventArgs e) { // Construct a bitmap from the button image resource. Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp"); // Save the image as a GIF. bmp1.Save("c:\\button.gif", System.Drawing.Imaging.ImageFormat.Gif); // Construct a new image from the GIF file. Bitmap bmp2 = new Bitmap("c:\\button.gif"); // Draw the two images. e.Graphics.DrawImage(bmp1, new Point(10, 10)); e.Graphics.DrawImage(bmp2, new Point(10, 40)); // Dispose of the image files. bmp1.Dispose(); bmp2.Dispose(); }
annotation
This constructor given type of namespace string name together with resources and find a match in the assembly manifest. For example, you may Button type and Button.bmp
passed to the constructor, it looks for the named System.Windows.Forms.Button.bmp
resource.