Image.GetBounds(GraphicsUnit) 메서드

정의

지정된 단위로 이미지의 범위를 가져옵니다.

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::GraphicsUnit % pageUnit);
public System.Drawing.RectangleF GetBounds (ref System.Drawing.GraphicsUnit pageUnit);
member this.GetBounds : GraphicsUnit -> System.Drawing.RectangleF
Public Function GetBounds (ByRef pageUnit As GraphicsUnit) As RectangleF

매개 변수

pageUnit
GraphicsUnit

경계 사각형의 단위를 나타내는 GraphicsUnit 값 중 하나입니다.

반환

지정된 단위로 이미지의 범위를 나타내는 RectangleF입니다.

예제

다음 코드 예제에서는 열거형을 사용하여 핸들에서 Icon 비트맵을 로드하는 방법과 메서드를 사용하여 GraphicsUnitRound 비트맵의 사각형 범위를 그리는 방법을 보여 줍니다.

이 예제는 Windows Forms 함께 사용하도록 설계되었습니다. 라는 Button2단추가 포함된 양식을 만듭니다. 코드를 양식에 붙여넣고 이 메서드를 단추의 Click 이벤트와 연결합니다.

void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   Bitmap^ bitmap1 = Bitmap::FromHicon( SystemIcons::Hand->Handle );
   Graphics^ formGraphics = this->CreateGraphics();
   GraphicsUnit units = GraphicsUnit::Point;
   RectangleF bmpRectangleF = bitmap1->GetBounds( units );
   Rectangle bmpRectangle = Rectangle::Round( bmpRectangleF );
   formGraphics->DrawRectangle( Pens::Blue, bmpRectangle );
   delete formGraphics;
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{

    Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Hand.Handle);
    Graphics formGraphics = this.CreateGraphics();
    GraphicsUnit units = GraphicsUnit.Point;

    RectangleF bmpRectangleF = bitmap1.GetBounds(ref units);
    Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);
    formGraphics.DrawRectangle(Pens.Blue, bmpRectangle);
    formGraphics.Dispose();
}
Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    Dim bitmap1 As Bitmap = Bitmap.FromHicon(SystemIcons.Hand.Handle)
    Dim formGraphics As Graphics = Me.CreateGraphics()
    Dim units As GraphicsUnit = GraphicsUnit.Point
    Dim bmpRectangleF As RectangleF = bitmap1.GetBounds(units)
    Dim bmpRectangle As Rectangle = Rectangle.Round(bmpRectangleF)
    formGraphics.DrawRectangle(Pens.Blue, bmpRectangle)
    formGraphics.Dispose()
End Sub

적용 대상