Gambar::Metode GetPropertyItem (gdiplusheaders.h)

Metode Image::GetPropertyItem mendapatkan item properti tertentu (bagian metadata) dari objek Gambar ini.

Sintaks

Status GetPropertyItem(
  [in]  PROPID       propId,
  [in]  UINT         propSize,
  [out] PropertyItem *buffer
);

Parameter

[in] propId

Jenis: PROPID

Bilangan bulat yang mengidentifikasi item properti yang akan diambil.

[in] propSize

Jenis: UINT

Bilangan bulat yang menentukan ukuran, dalam byte, item properti yang akan diambil. Panggil metode Image::GetPropertyItemSize untuk menentukan ukurannya.

[out] buffer

Jenis: PropertyItem*

Penunjuk ke objek PropertyItem yang menerima item properti.

Nilai kembali

Jenis: Status

Jika metode berhasil, metode mengembalikan Ok, yang merupakan elemen dari enumerasi Status .

Jika metode gagal, metode mengembalikan salah satu elemen lain dari enumerasi Status .

Keterangan

Metode Image::GetPropertyItem mengembalikan objek PropertyItem . Sebelum Anda memanggil Image::GetPropertyItem, Anda harus mengalokasikan buffer yang cukup besar untuk menerima objek tersebut — ukurannya bervariasi sesuai dengan jenis data dan nilai item properti. Anda dapat memanggil metode Image::GetPropertyItemSize dari objek Image untuk mendapatkan ukuran, dalam byte, dari buffer yang diperlukan.

Contoh

Contoh berikut membuat objek Gambar berdasarkan file JPEG. Kode mendapatkan pembuatan kamera yang mengambil gambar dengan meneruskan konstanta PropertyTagEquipMake ke metode Image::GetPropertyItem dari objek Image .

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT main()
{
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

   UINT size = 0;
   PropertyItem* propertyItem = NULL;
   Image* image = new Image(L"FakePhoto.jpg");

   // Assume that the image has a property item of type PropertyItemEquipMake.
   // Get the size of that property item.
   size = image->GetPropertyItemSize(PropertyTagEquipMake);

   // Allocate a buffer to receive the property item.
   propertyItem = (PropertyItem*)malloc(size);

   // Get the property item.
   image->GetPropertyItem(PropertyTagEquipMake, size, propertyItem);

   // Display the members of the retrieved PropertyItem object.
   printf("The length of the property item is %u.\n", propertyItem->length);
   printf("The data type of the property item is %u.\n", propertyItem->type);

   if(propertyItem->type == PropertyTagTypeASCII)
      printf("The value of the property item is %s.\n", propertyItem->value);

   free(propertyItem);
   delete image;
   GdiplusShutdown(gdiplusToken);
   return 0;
}

Kode sebelumnya, bersama dengan file tertentu, FakePhoto.jpg, menghasilkan output berikut. Perhatikan bahwa jenis data adalah 2, nilai konstanta PropertyTagTypeASCII yang ditentukan dalam Gdiplusimaging.h.

The length of the property item is 17.
The data type of the property item is 2.
The value of the property item is Northwind Traders.

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung Windows XP, Windows 2000 Professional [hanya aplikasi desktop]
Server minimum yang didukung Windows 2000 Server [hanya aplikasi desktop]
Target Platform Windows
Header gdiplusheaders.h (termasuk Gdiplus.h)
Pustaka Gdiplus.lib
DLL Gdiplus.dll

Lihat juga

Gambar

Gambar::GetAllPropertyItems

Gambar::GetPropertyCount

Gambar::GetPropertyIdList

Gambar::GetPropertyItemSize

Gambar::GetPropertySize

Gambar::RemovePropertyItem

Gambar::SetPropertyItem

PropertiItem

Membaca dan Menulis Metadata