ToolboxBitmapAttribute.GetImageFromResource(Type, String, Boolean) 方法

定義

根據嵌入組件的點陣圖資源傳回 Image 物件。

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

參數

t
Type

這個方法會在定義 t 參數所指定型別的組件搜尋內嵌點陣圖資源。 例如,如果您傳遞 typeof(ControlA) 至 t 參數,那麼這個方法會在定義 ControlA 的組件中搜尋。

imageName
String

內嵌點陣圖資源的名稱。

large
Boolean

指定此方法是會傳回大型影像 (true) 或小型影像 (false)。 小型影像為 16 x 16,而大型影像為 32 x 32。

傳回

以擷取的點陣圖為基礎的 Image 物件。

備註

這個方法會搜尋名為 namespace.imgName 的資源,其中 namespace 是包含 參數所 t 指定型別定義的命名空間。 例如,假設您將 typeof (ControlA) 傳遞至 t 參數,並將 “MyBitmap.bmp” 傳遞至 imgName 參數。 如果 ControlA 位於 AssemblyA.dll 的 NamespaceA 中,則此方法會搜尋 AssemblyA.dll 名為 NamespaceA.MyBitmap.bmp 的資源。

這個方法旨在擷取內嵌在元件中的 16 x 16 位圖資源。 不過,不需要內嵌位圖的大小為16 x 16。 從元件擷取的點陣圖 (,不論大小) 視為小型影像。 大型映像是藉由將「小型」映射調整為大小 32 x 32 來建立。 因此,不論從元件擷取的點陣圖大小為何,大型影像一律為 32 到 32。

適用於