C ++ bitmap constructor from http://msdn.microsoft.com/en-us/library/47591zc7.aspx

Source: Internet
Author: User
Bitmap Constructor (type, string) . NET Framework 4.5

Initializes a new instance of the bitmap class from a specified resource.

 

Namespace:System. Drawing
Assembly:System. Drawing (in system. Drawing. dll) C ++

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

C ++
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;        }    } 

. NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
. NET Framework client profile

Supported in: 4, 3.5 SP1

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.