ImageList.Draw 메서드

정의

지정된 이미지를 그립니다.

오버로드

Draw(Graphics, Point, Int32)

지정된 Graphics의 지정된 인덱스에서 나타내는 이미지를 지정된 위치에 그립니다.

Draw(Graphics, Int32, Int32, Int32)

지정된 Graphics의 지정된 인덱스에서 나타내는 이미지를 지정된 위치에 그립니다.

Draw(Graphics, Int32, Int32, Int32, Int32, Int32)

지정된 Graphics의 지정된 인덱스에서 나타내는 이미지를 지정된 위치 및 크기를 사용하여 그립니다.

Draw(Graphics, Point, Int32)

지정된 Graphics의 지정된 인덱스에서 나타내는 이미지를 지정된 위치에 그립니다.

public:
 void Draw(System::Drawing::Graphics ^ g, System::Drawing::Point pt, int index);
public void Draw (System.Drawing.Graphics g, System.Drawing.Point pt, int index);
member this.Draw : System.Drawing.Graphics * System.Drawing.Point * int -> unit
Public Sub Draw (g As Graphics, pt As Point, index As Integer)

매개 변수

g
Graphics

그릴 Graphics입니다.

pt
Point

해당 이미지를 그릴 위치이며 Point로 정의됩니다.

index
Int32

그릴 ImageList의 이미지 인덱스입니다.

예외

인덱스가 0보다 작은 경우

또는

인덱스가 이미지 목록의 이미지 개수보다 크거나 같은 경우

예제

다음 코드 예제에서는 생성 하는 방법을 ImageList보여 줍니다., 속성에 Images 이미지를 추가, 속성을 설정 ImageSize 하 고 메서드를 Draw 사용 하 여. 이 예제를 실행하려면 이름이 Button1단추를 포함하는 폼에 배치합니다. 이 예제에서는 c:\Windows\ 존재 FeatherTexture.bmp 한다고 가정합니다Gone Fishing.bmp. 비트맵이 시스템에 없거나 다른 위치에 있는 경우 이에 따라 예제를 변경합니다.

internal:
   System::Windows::Forms::ImageList^ ImageList1;

private:

   // Create an ImageList Object, populate it, and display
   // the images it contains.
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      
      // Construct the ImageList.
      ImageList1 = gcnew ImageList;
      
      // Set the ImageSize property to a larger size 
      // (the default is 16 x 16).
      ImageList1->ImageSize = System::Drawing::Size( 112, 112 );
      
      // Add two images to the list.
      ImageList1->Images->Add( Image::FromFile( "c:\\windows\\FeatherTexture.bmp" ) );
      ImageList1->Images->Add( Image::FromFile( "C:\\windows\\Gone Fishing.bmp" ) );
      
      // Get a Graphics object from the form's handle.
      Graphics^ theGraphics = Graphics::FromHwnd( this->Handle );
      
      // Loop through the images in the list, drawing each image.
      for ( int count = 0; count < ImageList1->Images->Count; count++ )
      {
         ImageList1->Draw( theGraphics, Point(85,85), count );
         
         // Call Application.DoEvents to force a repaint of the form.
         Application::DoEvents();
         
         // Call the Sleep method to allow the user to see the image.
         System::Threading::Thread::Sleep( 1000 );

      }
   }
internal System.Windows.Forms.ImageList ImageList1;

// Create an ImageList Object, populate it, and display
// the images it contains.
private void Button1_Click(System.Object sender, 
    System.EventArgs e)
{

    // Construct the ImageList.
    ImageList1 = new ImageList();

    // Set the ImageSize property to a larger size 
    // (the default is 16 x 16).
    ImageList1.ImageSize = new Size(112, 112);

    // Add two images to the list.
    ImageList1.Images.Add(
        Image.FromFile("c:\\windows\\FeatherTexture.bmp"));
    ImageList1.Images.Add(
        Image.FromFile("C:\\windows\\Gone Fishing.bmp"));

    // Get a Graphics object from the form's handle.
    Graphics theGraphics = Graphics.FromHwnd(this.Handle);

    // Loop through the images in the list, drawing each image.
    for(int count = 0; count < ImageList1.Images.Count; count++)
    {
        ImageList1.Draw(theGraphics, new Point(85, 85), count);

        // Call Application.DoEvents to force a repaint of the form.
        Application.DoEvents();

        // Call the Sleep method to allow the user to see the image.
        System.Threading.Thread.Sleep(1000);
    }
}
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList

' Create an ImageList Object, populate it, and display
' the images it contains.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    ' Construct the ImageList.
    ImageList1 = New ImageList

    ' Set the ImageSize property to a larger size 
    ' (the default is 16 x 16).
    ImageList1.ImageSize = New Size(112, 112)

    ' Add two images to the list.
    ImageList1.Images.Add(Image.FromFile _
        ("c:\windows\FeatherTexture.bmp"))
    ImageList1.Images.Add _
        (Image.FromFile("C:\windows\Gone Fishing.bmp"))

    Dim count As System.Int32

    ' Get a Graphics object from the form's handle.
    Dim theGraphics As Graphics = Graphics.FromHwnd(Me.Handle)

    ' Loop through the images in the list, drawing each image.
    For count = 0 To ImageList1.Images.Count - 1
        ImageList1.Draw(theGraphics, New Point(85, 85), count)

        ' Call Application.DoEvents to force a repaint of the form.
        Application.DoEvents()

        ' Call the Sleep method to allow the user to see the image.
        System.Threading.Thread.Sleep(1000)
    Next
End Sub

적용 대상

Draw(Graphics, Int32, Int32, Int32)

지정된 Graphics의 지정된 인덱스에서 나타내는 이미지를 지정된 위치에 그립니다.

public:
 void Draw(System::Drawing::Graphics ^ g, int x, int y, int index);
public void Draw (System.Drawing.Graphics g, int x, int y, int index);
member this.Draw : System.Drawing.Graphics * int * int * int -> unit
Public Sub Draw (g As Graphics, x As Integer, y As Integer, index As Integer)

매개 변수

g
Graphics

그릴 Graphics입니다.

x
Int32

이미지를 그릴 가로 위치입니다.

y
Int32

이미지를 그릴 세로 위치입니다.

index
Int32

그릴 ImageList의 이미지 인덱스입니다.

예외

인덱스가 0보다 작은 경우

또는

인덱스가 이미지 목록의 이미지 개수보다 크거나 같은 경우

적용 대상

Draw(Graphics, Int32, Int32, Int32, Int32, Int32)

지정된 Graphics의 지정된 인덱스에서 나타내는 이미지를 지정된 위치 및 크기를 사용하여 그립니다.

public:
 void Draw(System::Drawing::Graphics ^ g, int x, int y, int width, int height, int index);
public void Draw (System.Drawing.Graphics g, int x, int y, int width, int height, int index);
member this.Draw : System.Drawing.Graphics * int * int * int * int * int -> unit
Public Sub Draw (g As Graphics, x As Integer, y As Integer, width As Integer, height As Integer, index As Integer)

매개 변수

g
Graphics

그릴 Graphics입니다.

x
Int32

이미지를 그릴 가로 위치입니다.

y
Int32

이미지를 그릴 세로 위치입니다.

width
Int32

대상 이미지의 너비(픽셀)입니다.

height
Int32

대상 이미지의 높이(픽셀)입니다.

index
Int32

그릴 ImageList의 이미지 인덱스입니다.

예외

인덱스가 0보다 작은 경우

또는

인덱스가 이미지 목록의 이미지 개수보다 크거나 같은 경우

설명

제공된 경계에 맞게 필요에 따라 이미지가 늘어나거나 압축됩니다.

적용 대상