GraphicsUnit Enumerazione

Definizione

Specifica l'unità di misura dei dati indicati.

public enum class GraphicsUnit
public enum GraphicsUnit
type GraphicsUnit = 
Public Enum GraphicsUnit
Ereditarietà
GraphicsUnit

Campi

Display 1

Specifica l'unità di misura della periferica di visualizzazione. Si tratta in genere di pixel per gli schermi video e di 1/100 di pollice per le stampanti.

Document 5

Specifica come unità di misura quella del documento: 1/300 di pollice.

Inch 4

Specifica come unità di misura il pollice.

Millimeter 6

Specifica come unità di misura il millimetro.

Pixel 2

Specifica come unità di misura un pixel di periferica.

Point 3

Specifica come unità di misura un punto della stampante, 1/72 di pollice.

World 0

Specifica come unità di misura l'unità del sistema di coordinate globali.

Esempio

Nell'esempio di codice seguente viene illustrato come caricare una bitmap da un Icon handle, usando l'enumerazione e l'uso GraphicsUnit del Round metodo per disegnare i limiti rettangoli di una bitmap.

Questo esempio è progettato per essere usato con Windows Forms. Creare un modulo contenente un pulsante denominato Button2. Incollare il codice nel modulo e associare questo metodo all'evento del Click pulsante.

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

Si applica a