C++ Bitmap Constructor from http://msdn.microsoft.com/en-us/library/47591zc7.aspx
Bitmap Constructor (Type, String)
Initializes a new instance of the Bitmap class from a specified resource.
Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
public:
Bitmap(
Type^ type,
String^ resource
)
Parameters
- type
- Type: System::Type
The class used to extract the resource.
- resource
- Type: System::String
The name of the resource.
This constructor combines the namespace of the given type with the string name of the resource and looks for a match in the assembly manifest. For example you can pass in the Button type and Button.bmp to this constructor and it will look for a resource named System.Windows.Forms.Button.bmp.
The following code example demonstrates how to construct a bitmap from a type, 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, passing e as PaintEventArgs
private: void ConstructFromResourceSaveAsGif(PaintEventArgs^ e) { // Construct a bitmap from the button image resource. Bitmap^ bmp1 = gcnew Bitmap(Button::typeid, "Button.bmp"); String^ savePath = Environment::GetEnvironmentVariable("TEMP") + "\\Button.bmp"; try { // Save the image as a GIF. bmp1->Save(savePath, System::Drawing::Imaging::ImageFormat::Gif); } catch (IOException^) { // Carry on regardless } // Construct a new image from the GIF file. Bitmap^ bmp2 = nullptr; if (File::Exists(savePath)) { bmp2 = gcnew Bitmap(savePath); } // Draw the two images. e->Graphics->DrawImage(bmp1, Point(10, 10)); // If bmp1 did not save to disk, bmp2 may be null if (bmp2 != nullptr) { e->Graphics->DrawImage(bmp2, Point(10, 40)); } // Dispose of the image files. delete bmp1; if (bmp2 != nullptr) { delete bmp2; } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.