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
指定此方法返回大型图像(true)还是小图像(false)。 小图像为 16×16,大图像为 32 x 32。
返回
Image基于检索的位图的对象。
注解
此方法搜索名为 namespace.imgName 的资源,其中命名空间是包含参数所指定 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。