Gambar::Metode GetPropertySize (gdiplusheaders.h)

Metode Image::GetPropertySize mendapatkan ukuran total, dalam byte, dari semua item properti yang disimpan dalam objek Gambar ini. Metode Image::GetPropertySize juga mendapatkan jumlah item properti yang disimpan dalam objek Gambar ini.

Sintaks

Status GetPropertySize(
  [out] UINT *totalBufferSize,
  [out] UINT *numProperties
);

Parameter

[out] totalBufferSize

Jenis: UINT*

Penunjuk ke UINT yang menerima ukuran total, dalam byte, dari semua item properti.

[out] numProperties

Jenis: UINT*

Penunjuk ke UINT yang menerima jumlah item properti.

Menampilkan nilai

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

Windows GDI+ menyimpan satu per satu metadata dalam objek PropertyItem . Metode Image::GetAllPropertyItems mengembalikan array objek PropertyItem . Sebelum Anda memanggil Image::GetAllPropertyItems, Anda harus mengalokasikan buffer yang cukup besar untuk menerima array tersebut. Anda dapat memanggil metode Image::GetPropertySize dari objek Image untuk mendapatkan ukuran, dalam byte, dari buffer yang diperlukan. Metode Image::GetPropertySize juga memberi Anda jumlah properti (potongan metadata) dalam gambar.

Contoh

Contoh berikut membuat objek Gambar berdasarkan file JPEG. Kode memanggil metode Image::GetAllPropertyItems dari objek Image tersebut untuk mendapatkan item propertinya (metadata).

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

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

   // Create an Image object based on a JPEG file.
   Image* image = new Image(L"FakePhoto.jpg"); 

  // Find out how many property items are in the image, and find out the
   // required size of the buffer that will receive those property items.
   UINT totalBufferSize;
   UINT numProperties;
   image->GetPropertySize(&totalBufferSize, &numProperties);

   // Allocate the buffer that will receive the property items.
   PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);

   // Fill the buffer.
   image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);

   // Print the ID of each property item.
   for(UINT j = 0; j < numProperties; ++j)
   {
      printf("%x\n", pAllItems[j].id);
   }

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

Kode sebelumnya, bersama dengan file tertentu, FakePhoto.jpg, menghasilkan output berikut:

320
10f
110
9003
829a
5090
5091

Output sebelumnya menunjukkan nilai heksadesimal dari setiap pengidentifikasi properti. Anda dapat mencari angka-angka tersebut di Gdiplusimaging.h dan mencari tahu bahwa angka tersebut mewakili tag properti berikut.

Nilai heksadesimal Tag properti
0x0320 PropertyTagImageTitle
0x010f PropertyTagEquipMake
0x0110 PropertyTagEquipModel
0x9003 PropertyTagExifDTOriginal
0x829a PropertyTagExifExposureTime
0x5090 PropertyTagLuminanceTable
0x5091 PropertyTagChrominanceTable
 

Persyaratan

   
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::GetPropertyItem

Gambar::GetPropertyItemSize

Gambar::RemovePropertyItem

Gambar::SetPropertyItem

PropertyItem

Membaca dan Menulis Metadata