Image.GetPropertyItem メソッド
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim instance As Image Dim propid As Integer Dim returnValue As PropertyItem returnValue = instance.GetPropertyItem(propid)
戻り値
このメソッドが取得する PropertyItem。


PropertyItem クラスにはパブリック コンストラクタがないため、プロパティ項目の設定は困難です。この制約を回避する方法の 1 つは、PropertyItems プロパティ値を取得するか、既にプロパティ項目を持つ Image の GetPropertyItem メソッドを呼び出して、PropertyItem を取得することです。その後、PropertyItem のフィールドを設定して、SetPropertyItem に渡すことができます。

GetPropertyItem メソッドと SetPropertyItem メソッドを使用する方法を次のコード例に示します。この例は、Windows フォームでの使用を意図してデザインされています。この例を実行するには、コードをフォームに貼り付け、e を PaintEventArgs として渡して DemonstratePropertyItem メソッドを呼び出すことで、フォームの Paint イベントを処理します。
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
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 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.set_Id(20625); // Set the PropertyItem for image2. image2.SetPropertyItem(propItem); // Draw the image. e.get_Graphics().DrawImage(image2, 20, 20); } //DemonstratePropertyItem

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Image.GetPropertyItem メソッドのページへのリンク