Image.GetPropertyItem(Int32) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает указанный элемент свойства из этого 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
Параметры
- propid
- Int32
Идентификатор элемента свойства, который требуется получить.
Возвращаемое значение
Возвращает PropertyItem этот метод.
Исключения
Формат изображения этого изображения не поддерживает элементы свойств.
Примеры
В следующем примере кода показано, как использовать GetPropertyItem методы и SetPropertyItem методы. В этом примере вызывается GetPropertyItem передача значения идентификатора. Список значений идентификаторов см. в разделе Id. Этот пример предназначен для использования с Windows Forms. Чтобы запустить этот пример, вставьте его в форму и обработайте событие формы Paint , вызвав DemonstratePropertyItem метод, передав e как 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
Комментарии
Список идентификаторов элементов свойств и ссылок на дополнительные сведения см. в разделе Id.
Трудно задать элементы свойств, так как PropertyItem класс не имеет открытых конструкторов. Один из способов обойти это ограничение заключается PropertyItem в получении PropertyItems значения свойства или вызове GetPropertyItem метода Image , который уже имеет элементы свойства. Затем можно задать поля PropertyItem и передать его SetPropertyItemв .