Icon クラスの新しいインスタンスを初期化し、要求されたサイズに一致するアイコンを検索します。
名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
'宣言
Public Sub New ( _
original As Icon, _
width As Integer, _
height As Integer _
)
'使用
Dim original As Icon
Dim width As Integer
Dim height As Integer
Dim instance As New Icon(original, width, height)
public Icon (
Icon original,
int width,
int height
)
public:
Icon (
Icon^ original,
int width,
int height
)
public Icon (
Icon original,
int width,
int height
)
public function Icon (
original : Icon,
width : int,
height : int
)
パラメータ
- original
別のサイズの読み込み元のアイコン。
- width
新しいアイコンの幅。
- height
新しいアイコンの高さ。
解説
要求サイズに一致するアイコンが見つからない場合は、最も近いものが使用されます。original パラメータが単一サイズの Icon である場合、このメソッドはアイコンの複製だけを行います。アイコンのサイズを変更するには、DrawImage メソッドの拡大機能を使用します。
使用例
ToBitmap メソッドを使用する方法を次のコード例に示します。この例は、Windows フォームでの使用を意図してデザインされています。フォームを作成し、次のコードを貼り付けます。フォームの Paint イベント ハンドラで IconToBitmap メソッドを呼び出し、e を PaintEventArgs として渡します。
Private Sub IconToBitmap(ByVal e As PaintEventArgs)
' Construct an Icon.
Dim icon1 As New Icon(SystemIcons.Exclamation, 40, 40)
' Call ToBitmap to convert it.
Dim bmp As Bitmap = icon1.ToBitmap()
' Draw the bitmap.
e.Graphics.DrawImage(bmp, New Point(30, 30))
End Sub
private void IconToBitmap(PaintEventArgs e)
{
// Construct an Icon.
Icon icon1 = new Icon(SystemIcons.Exclamation, 40, 40);
// Call ToBitmap to convert it.
Bitmap bmp = icon1.ToBitmap();
// Draw the bitmap.
e.Graphics.DrawImage(bmp, new Point(30, 30));
}
private:
void IconToBitmap( PaintEventArgs^ e )
{
// Construct an Icon.
System::Drawing::Icon^ icon1 = gcnew System::Drawing::Icon( SystemIcons::Exclamation,40,40 );
// Call ToBitmap to convert it.
Bitmap^ bmp = icon1->ToBitmap();
// Draw the bitmap.
e->Graphics->DrawImage( bmp, Point(30,30) );
}
private void IconToBitmap(PaintEventArgs e)
{
// Construct an Icon.
Icon icon1 = new Icon(SystemIcons.get_Exclamation(), 40, 40);
// Call ToBitmap to convert it.
Bitmap bmp = icon1.ToBitmap();
// Draw the bitmap.
e.get_Graphics().DrawImage(bmp, new Point(30, 30));
} //IconToBitmap
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0