Image.GetPropertyItem(Int32) Metoda

Definicja

Pobiera określony element właściwości z tego Imageelementu .

public:
 System::Drawing::Imaging::PropertyItem ^ GetPropertyItem(int propid);
public System.Drawing.Imaging.PropertyItem GetPropertyItem (int propid);
public System.Drawing.Imaging.PropertyItem? GetPropertyItem (int propid);
member this.GetPropertyItem : int -> System.Drawing.Imaging.PropertyItem
Public Function GetPropertyItem (propid As Integer) As PropertyItem

Parametry

propid
Int32

Identyfikator elementu właściwości do pobrania.

Zwraca

Ta PropertyItem metoda jest pobierana.

Wyjątki

Format obrazu tego obrazu nie obsługuje elementów właściwości.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać GetPropertyItem metod i SetPropertyItem . W tym przykładzie jest wywoływana GetPropertyItem przekazywanie wartości identyfikatora. Aby uzyskać listę wartości identyfikatorów, Idzobacz . Ten przykład jest przeznaczony do użycia z Windows Forms. Aby uruchomić ten przykład, wklej go w formularzu i obsłuż zdarzenie formularza Paint , wywołując metodę DemonstratePropertyItem , przekazując e jako PaintEventArgs.

private:
   void DemonstratePropertyItem( PaintEventArgs^ e )
   {
      // Create two images.
      Image^ image1 = Image::FromFile( "c:\\FakePhoto1.jpg" );
      Image^ image2 = Image::FromFile( "c:\\FakePhoto2.jpg" );

      // Get a PropertyItem from image1.
      PropertyItem^ propItem = image1->GetPropertyItem( 20624 );

      // Change the ID of the PropertyItem.
      propItem->Id = 20625;

      // Set the PropertyItem for image2.
      image2->SetPropertyItem( propItem );

      // Draw the image.
      e->Graphics->DrawImage( image2, 20.0F, 20.0F );
   }
private void DemonstratePropertyItem(PaintEventArgs e)
{

    // Create two images.
    Image image1 = Image.FromFile("c:\\FakePhoto1.jpg");
    Image image2 = Image.FromFile("c:\\FakePhoto2.jpg");

    // Get a PropertyItem from image1.
    PropertyItem propItem = image1.GetPropertyItem(20624);

    // Change the ID of the PropertyItem.
    propItem.Id = 20625;

    // Set the PropertyItem for image2.
    image2.SetPropertyItem(propItem);

    // Draw the image.
    e.Graphics.DrawImage(image2, 20.0F, 20.0F);
}
Private Sub DemonstratePropertyItem(ByVal e As PaintEventArgs)

    ' Create two images.
    Dim image1 As Image = Image.FromFile("c:\FakePhoto1.jpg")
    Dim image2 As Image = Image.FromFile("c:\FakePhoto2.jpg")

    ' Get a PropertyItem from image1.
    Dim propItem As PropertyItem = image1.GetPropertyItem(20624)

    ' Change the ID of the PropertyItem.
    propItem.Id = 20625

    ' Set the PropertyItem for image2.
    image2.SetPropertyItem(propItem)

    ' Draw the image.
    e.Graphics.DrawImage(image2, 20.0F, 20.0F)
End Sub

Uwagi

Aby uzyskać listę identyfikatorów elementów właściwości i linki do dodatkowych informacji, zobacz Id.

Trudno jest ustawić elementy właściwości, ponieważ PropertyItem klasa nie ma publicznych konstruktorów. Jednym ze sposobów obejścia tego ograniczenia jest uzyskanie PropertyItem wartości właściwości przez pobranie PropertyItems wartości właściwości lub wywołanie GetPropertyItem metody Image , która ma już elementy właściwości. Następnie możesz ustawić pola obiektu PropertyItem i przekazać je do elementu SetPropertyItem.

Dotyczy