Image.GetPropertyItem(Int32) Método

Definição

Obtém o item de propriedade especificado deste Image.Gets the specified property item from this Image.

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

Parâmetros

propid
Int32

A ID do item da propriedade que será obtida.The ID of the property item to get.

Retornos

PropertyItem

O PropertyItem que esse método obtém.The PropertyItem this method gets.

Exceções

O formato de imagem dessa imagem não dá suporte a itens de propriedade.The image format of this image does not support property items.

Exemplos

O exemplo de código a seguir demonstra como usar GetPropertyItem os SetPropertyItem métodos e.The following code example demonstrates how to use the GetPropertyItem and SetPropertyItem methods. Este exemplo chama GetPropertyItem a passagem de um valor de ID.This example calls GetPropertyItem passing an ID value. Para obter uma lista de valores de ID, consulte Id .For a list of ID values see, Id. Este exemplo foi projetado para ser usado com Windows Forms.This example is designed to be used with Windows Forms. Para executar este exemplo, Cole-o em um formulário e manipule o evento do formulário Paint chamando o DemonstratePropertyItem método, passando e como PaintEventArgs .To run this example, paste it into a form, and handle the form's Paint event by calling the DemonstratePropertyItem method, passing e as 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

Comentários

Para obter uma lista de IDs de item de propriedade e links para mais informações, consulte Id .For a list of property item IDs and links to more information, see Id.

É difícil definir itens de propriedade, porque a PropertyItem classe não tem construtores públicos.It is difficult to set property items, because the PropertyItem class has no public constructors. Uma maneira de contornar essa restrição é obter um PropertyItem recuperando o valor da PropertyItems propriedade ou chamando o GetPropertyItem método de um Image que já tem itens de propriedade.One way to work around this restriction is to obtain a PropertyItem by retrieving the PropertyItems property value or calling the GetPropertyItem method of an Image that already has property items. Em seguida, você pode definir os campos do PropertyItem e passá-los para SetPropertyItem .Then you can set the fields of the PropertyItem and pass it to SetPropertyItem.

Aplica-se a