Edit

Share via


ToolboxBitmapAttribute.GetImageFromResource(Type, String, Boolean) Method

Definition

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

public:
 static System::Drawing::Image ^ GetImageFromResource(Type ^ t, System::String ^ imageName, bool large);
public static System.Drawing.Image? GetImageFromResource (Type t, string? imageName, bool large);
public static System.Drawing.Image GetImageFromResource (Type t, string imageName, bool large);
static member GetImageFromResource : Type * string * bool -> System.Drawing.Image
Public Shared Function GetImageFromResource (t As Type, imageName As String, large As Boolean) As Image

Parameters

t
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
String

The name of the embedded bitmap resource.

large
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.

Returns

An Image object based on the retrieved bitmap.

Remarks

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.

Applies to