Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ToolboxBitmapAttribute::GetImageFromResource Method (Type^, String^, Boolean)

 

Returns an Image object based on a bitmap resource that is embedded in an assembly.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public:
static Image^ GetImageFromResource(
	Type^ t,
	String^ imageName,
	bool large
)

Parameters

t
Type: System::Type^

This method searches for an embedded bitmap resource in the assembly that defines the type specified by the t parameter. For example, if you pass typeof(ControlA) to the t parameter, then this method searches the assembly that defines ControlA.

imageName
Type: System::String^

The name of the embedded bitmap resource.

large
Type: System::Boolean

Specifies whether this method returns a large image (true)or a small image (false). The small image is 16 by 16, and the large image is 32 x 32.

Return Value

Type: System.Drawing::Image^

An Image object based on the retrieved bitmap.

This method searches for a resource named namespace.imgName, where namespace is the namespace containing the definition of the type specified by the t parameter. For example, suppose you pass typeof(ControlA) to the t parameter and you pass "MyBitmap.bmp" to the imgName parameter. If ControlA is in NamespaceA in AssemblyA.dll, then this method searches AssemblyA.dll for a resource named NamespaceA.MyBitmap.bmp.

This method is intended to retrieve a 16 x 16 bitmap resource that is embedded in an assembly. However, there is no requirement that the embedded bitmap has a size of 16 x 16. The bitmap that is retrieved from the assembly (no matter what size) is considered the small image. The large image is created by scaling the "small" image to a size of 32 x 32. So the large image will always be 32 by 32, regardless of the size of the bitmap retrieved from the assembly.

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft