Graphics.DrawIcon 메서드

정의

지정된 Icon에 의해 나타나는 이미지를 지정된 좌표에 그립니다.

오버로드

DrawIcon(Icon, Rectangle)

지정된 Icon에 의해 나타나는 이미지를 Rectangle 구조체에 의해 지정된 영역 안에 그립니다.

DrawIcon(Icon, Int32, Int32)

지정된 Icon에 의해 나타나는 이미지를 지정된 좌표에 그립니다.

DrawIcon(Icon, Rectangle)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 Icon에 의해 나타나는 이미지를 Rectangle 구조체에 의해 지정된 영역 안에 그립니다.

public:
 void DrawIcon(System::Drawing::Icon ^ icon, System::Drawing::Rectangle targetRect);
public void DrawIcon (System.Drawing.Icon icon, System.Drawing.Rectangle targetRect);
member this.DrawIcon : System.Drawing.Icon * System.Drawing.Rectangle -> unit
Public Sub DrawIcon (icon As Icon, targetRect As Rectangle)

매개 변수

icon
Icon

그릴 Icon입니다.

targetRect
Rectangle

표시 화면에 결과로 나타날 이미지의 위치와 크기를 지정하는 Rectangle 구조체입니다. icon 매개 변수에 포함된 이미지는 이 사각형 영역의 크기에 맞게 크기가 조정됩니다.

예외

icon이(가) null인 경우

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 예제 폴더의 표준 Windows 아이콘 파일 SampIcon.ico 아이콘을 만듭니다.

  • 아이콘을 그릴 사각형을 만듭니다.

  • 화면에 아이콘을 그립니다.

사각형의 위치는 화면에서 아이콘을 찾고 사각형의 크기에 따라 그려진 아이콘의 크기가 결정됩니다.

private:
   void DrawIconRectangle( PaintEventArgs^ e )
   {
      // Create icon.
      System::Drawing::Icon^ newIcon = gcnew System::Drawing::Icon( "SampIcon.ico" );

      // Create rectangle for icon.
      Rectangle rect = Rectangle(100,100,200,200);

      // Draw icon to screen.
      e->Graphics->DrawIcon( newIcon, rect );
   }
private void DrawIconRectangle(PaintEventArgs e)
{        
    // Create icon.
    Icon newIcon = new Icon("SampIcon.ico");
             
    // Create rectangle for icon.
    Rectangle rect = new Rectangle(100, 100, 200, 200);
             
    // Draw icon to screen.
    e.Graphics.DrawIcon(newIcon, rect);
}
Private Sub DrawIconRectangle(ByVal e As PaintEventArgs)

    ' Create icon.
    Dim newIcon As New Icon("SampIcon.ico")

    ' Create rectangle for icon.
    Dim rect As New Rectangle(100, 100, 200, 200)

    ' Draw icon to screen.
    e.Graphics.DrawIcon(newIcon, rect)
End Sub

적용 대상

DrawIcon(Icon, Int32, Int32)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

지정된 Icon에 의해 나타나는 이미지를 지정된 좌표에 그립니다.

public:
 void DrawIcon(System::Drawing::Icon ^ icon, int x, int y);
public void DrawIcon (System.Drawing.Icon icon, int x, int y);
member this.DrawIcon : System.Drawing.Icon * int * int -> unit
Public Sub DrawIcon (icon As Icon, x As Integer, y As Integer)

매개 변수

icon
Icon

그릴 Icon입니다.

x
Int32

그려지는 이미지의 왼쪽 위 모퉁이에 대한 X 좌표입니다.

y
Int32

그려지는 이미지의 왼쪽 위 모퉁이에 대한 Y 좌표입니다.

예외

icon이(가) null인 경우

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • 예제 폴더의 표준 Windows 아이콘 파일 SampIcon.ico 아이콘을 만듭니다.

  • 아이콘을 그릴 왼쪽 위 모서리의 좌표를 만듭니다.

  • 화면에 아이콘을 그립니다.

그려진 아이콘의 크기가 조정되지 않습니다.

private:
   void DrawIconInt( PaintEventArgs^ e )
   {

      // Create icon.
      System::Drawing::Icon^ newIcon = gcnew System::Drawing::Icon( "SampIcon.ico" );

      // Create coordinates for upper-left corner of icon.
      int x = 100;
      int y = 100;

      // Draw icon to screen.
      e->Graphics->DrawIcon( newIcon, x, y );
   }
private void DrawIconInt(PaintEventArgs e)
{
    // Create icon.
    Icon newIcon = new Icon("SampIcon.ico");
             
    // Create coordinates for upper-left corner of icon.
    int x = 100;
    int y = 100;
             
    // Draw icon to screen.
    e.Graphics.DrawIcon(newIcon, x, y);
}
Private Sub DrawIconInt(ByVal e As PaintEventArgs)

    ' Create icon.
    Dim newIcon As New Icon("SampIcon.ico")

    ' Create coordinates for upper-left corner of icon.
    Dim x As Integer = 100
    Dim y As Integer = 100

    ' Draw icon to screen.
    e.Graphics.DrawIcon(newIcon, x, y)
End Sub

적용 대상