ToolboxBitmapAttribute.GetImageFromResource(Type, String, Boolean) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳 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
指定此方法回傳大影像(真)還是小影像(假)。 小圖為16乘16,大圖為32 x 32。
傳回
一個 Image 基於取回點陣圖的物件。
備註
此方法搜尋名為 namespace.imgName 的資源,其中 namespace 是包含參數所指定 t 類型定義的命名空間。 舉例來說,假設你把 typeof(ControlA) 傳給 t 參數,然後把「MyBitmap.bmp」傳給 imgName 參數。 若 ControlA 位於 AssemblyA.dll的命名空間 A,則此方法會搜尋 AssemblyA.dll 一個名為 NamespaceA.MyBitmap.bmp的資源。
此方法旨在擷取嵌入組件中的 16 x 16 位圖資源。 然而,嵌入的點陣圖尺寸不要求為 16 x 16。 從組件中擷取的位圖(無論大小)被視為小影像。 大影像是將「小」影像縮放成 32 x 32 的尺寸。 因此,無論從組裝中取得的點陣圖大小,大影像都會是 32 x 32。