This documentation is archived and is not being maintained.

ToolboxBitmapAttribute.GetImageFromResource Method

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


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.
Type: System.String
The name of the embedded bitmap resource.
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

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.