Graphics.FromHdc 메서드

정의

디바이스 컨텍스트에 대한 지정된 핸들에서 새 Graphics를 만듭니다.

오버로드

FromHdc(IntPtr)

디바이스 컨텍스트에 대한 지정된 핸들에서 새 Graphics를 만듭니다.

FromHdc(IntPtr, IntPtr)

디바이스 컨텍스트에 대한 지정된 핸들과 디바이스에 대한 핸들에서 새 Graphics를 만듭니다.

FromHdc(IntPtr)

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

디바이스 컨텍스트에 대한 지정된 핸들에서 새 Graphics를 만듭니다.

public:
 static System::Drawing::Graphics ^ FromHdc(IntPtr hdc);
public static System.Drawing.Graphics FromHdc (IntPtr hdc);
static member FromHdc : nativeint -> System.Drawing.Graphics
Public Shared Function FromHdc (hdc As IntPtr) As Graphics

매개 변수

hdc
IntPtr

nativeint

디바이스 컨텍스트에 대한 핸들입니다.

반환

이 메서드는 지정된 디바이스 컨텍스트에 대한 새 Graphics를 반환합니다.

예제

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

  • 내부 포인터 형식 변수를 만들고 hdc 형식의 그래픽 개체의 디바이스 컨텍스트에 대 한 핸들을 설정 합니다.

  • 를 사용하여 hdc새 그래픽 개체를 만듭니다.

  • 화면의 새 그래픽 개체를 사용하여 사각형을 그립니다.

  • 를 사용하여 hdc새 그래픽 개체를 해제합니다.

public:
   void FromHdcHdc( PaintEventArgs^ e )
   {
      // Get handle to device context.
      IntPtr hdc = e->Graphics->GetHdc();

      // Create new graphics object using handle to device context.
      Graphics^ newGraphics = Graphics::FromHdc( hdc );

      // Draw rectangle to screen.
      newGraphics->DrawRectangle( gcnew Pen( Color::Red,3.0f ), 0, 0, 200, 100 );

      // Release handle to device context and dispose of the      // Graphics object
      e->Graphics->ReleaseHdc( hdc );
      delete newGraphics;
   }
private void FromHdcHdc(PaintEventArgs e)
{
    // Get handle to device context.
    IntPtr hdc = e.Graphics.GetHdc();

    // Create new graphics object using handle to device context.
    Graphics newGraphics = Graphics.FromHdc(hdc);

    // Draw rectangle to screen.
    newGraphics.DrawRectangle(new Pen(Color.Red, 3), 0, 0, 200, 100);

    // Release handle to device context and dispose of the      // Graphics object
    e.Graphics.ReleaseHdc(hdc);
    newGraphics.Dispose();
}
<System.Security.Permissions.SecurityPermission( _
System.Security.Permissions.SecurityAction.LinkDemand, Flags := _
System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Private Sub FromHdcHdc(ByVal e As PaintEventArgs)

    ' Get handle to device context.
    Dim hdc As IntPtr = e.Graphics.GetHdc()

    ' Create new graphics object using handle to device context.
    Dim newGraphics As Graphics = Graphics.FromHdc(hdc)

    ' Draw rectangle to screen.
    newGraphics.DrawRectangle(New Pen(Color.Red, 3), 0, 0, 200, 100)

    ' Release handle to device context and dispose of the Graphics 	' object
    e.Graphics.ReleaseHdc(hdc)
    newGraphics.Dispose()
End Sub

설명

메서드를 항상 호출하여 메서드에서 DisposeGraphics 만든 및 관련 리소스를 FromHdc 해제해야 합니다.

디스플레이 디바이스에 연결된 ICM 색 프로필이 있더라도 GDI+는 기본적으로 해당 프로필을 사용하지 않습니다. 에 대해 ICM을 Graphics사용하도록 설정하려면 HDC(및 ICM_ON)를 함수에 전달한 후 HDC에서 을 SetICMMode 생성 Graphics 합니다. 다음 수행한 모든 그리기를 Graphics 디스플레이 디바이스와 연결 된 ICM 프로필에 따라 조정 됩니다. ICM을 사용하도록 설정하면 성능이 저하됩니다.

호출 시 디바이스 컨텍스트 (예: 매핑 모드, 논리 단위 및 like) 상태의 FromHdc 렌더링 작업에 영향을 줄 수는 Graphics합니다.

적용 대상

FromHdc(IntPtr, IntPtr)

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

디바이스 컨텍스트에 대한 지정된 핸들과 디바이스에 대한 핸들에서 새 Graphics를 만듭니다.

public:
 static System::Drawing::Graphics ^ FromHdc(IntPtr hdc, IntPtr hdevice);
public static System.Drawing.Graphics FromHdc (IntPtr hdc, IntPtr hdevice);
static member FromHdc : nativeint * nativeint -> System.Drawing.Graphics
Public Shared Function FromHdc (hdc As IntPtr, hdevice As IntPtr) As Graphics

매개 변수

hdc
IntPtr

nativeint

디바이스 컨텍스트에 대한 핸들입니다.

hdevice
IntPtr

nativeint

디바이스 핸들입니다.

반환

이 메서드는 지정된 디바이스 컨텍스트와 디바이스에 대한 새 Graphics를 반환합니다.

설명

메서드를 항상 호출하여 메서드에서 DisposeGraphics 만든 및 관련 리소스를 FromHdc 해제해야 합니다.

디스플레이 디바이스에 연결된 ICM 색 프로필이 있더라도 GDI+는 기본적으로 해당 프로필을 사용하지 않습니다. 에 대해 ICM을 Graphics사용하도록 설정하려면 HDC(및 ICM_ON)를 함수에 전달한 후 HDC에서 을 SetICMMode 생성 Graphics 합니다. 다음 수행한 모든 그리기를 Graphics 디스플레이 디바이스와 연결 된 ICM 프로필에 따라 조정 됩니다. ICM을 사용하도록 설정하면 성능이 저하됩니다.

호출 시 디바이스 컨텍스트 (예: 매핑 모드, 논리 단위 및 like) 상태의 FromHdc 렌더링 작업에 영향을 줄 수는 Graphics합니다.

디바이스 핸들을 일반적으로 특정 프린터 기능 쿼리 됩니다.

적용 대상