Image.GetBounds(GraphicsUnit) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá hranice obrázku v zadané jednotce.
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
Parametry
- pageUnit
- GraphicsUnit
Jedna z GraphicsUnit hodnot označujících měrnou jednotku pro ohraničující obdélník.
Návraty
To RectangleF představuje hranice obrázku v zadané jednotce.
Příklady
Následující příklad kódu ukazuje, jak načíst rastrový obrázek z úchytu Icon , pomocí GraphicsUnit výčtu a jak pomocí Round metody nakreslit hranice obdélníku rastrového obrázku.
Tento příklad je navržený tak, aby se používal s model Windows Forms. Vytvořte formulář, který obsahuje tlačítko s názvem Button2. Vložte kód do formuláře a přidružte tuto metodu k události tlačítka 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