Image.GetBounds(GraphicsUnit) Yöntem

Tanım

Belirtilen ünitedeki görüntünün sınırlarını alır.

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

Parametreler

pageUnit
GraphicsUnit

GraphicsUnit Sınırlayıcı dikdörtgen için ölçü birimini gösteren değerlerden biri.

Döndürülenler

RectangleF Belirtilen ünitede görüntünün sınırlarını temsil eden.

Örnekler

Aşağıdaki kod örneği, bir tanıtıcıdan Icon bit eşlem yüklemeyi, numaralandırmayı GraphicsUnit kullanmayı ve bir bit eşlem dikdörtgen sınırlarını çizmek için yöntemini kullanmayı Round gösterir.

Bu örnek, Windows Forms ile kullanılacak şekilde tasarlanmıştır. adlı Button2düğmeyi içeren bir form oluşturun. Kodu forma yapıştırın ve bu yöntemi düğmenin Click olayıyla ilişkilendirin.

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

Şunlara uygulanır