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

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.

转载于:https://www.cnblogs.com/songtzu/archive/2012/12/25/2831716.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值