Gambar::Metode GetAllPropertyItems (gdiplusheaders.h)
Metode Image::GetAllPropertyItems mendapatkan semua item properti (metadata) yang disimpan dalam objek Gambar ini.
Sintaks
Status GetAllPropertyItems(
[in] UINT totalBufferSize,
[in] UINT numProperties,
[out] PropertyItem *allItems
);
Parameter
[in] totalBufferSize
Jenis: UINT
Bilangan bulat yang menentukan ukuran, dalam byte, dari buffer allItems . Panggil metode Image::GetPropertySize untuk mendapatkan ukuran yang diperlukan.
[in] numProperties
Jenis: UINT
Bilangan bulat yang menentukan jumlah properti dalam gambar. Panggil metode Image::GetPropertySize untuk mendapatkan nomor ini.
[out] allItems
Jenis: PropertyItem*
Penunjuk ke array objek PropertyItem yang menerima 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
Beberapa file gambar berisi metadata yang dapat Anda baca untuk menentukan fitur gambar. Misalnya, foto digital mungkin berisi metadata yang dapat Anda baca untuk menentukan pembuatan dan model kamera yang digunakan untuk mengambil gambar.
GDI+ menyimpan satu bagian metadata individual 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.
Beberapa enumerasi dan konstanta yang terkait dengan metadata gambar didefinisikan dalam Gdiplusimaging.h.
Contoh
Contoh berikut membuat objek Gambar berdasarkan file JPEG. Kode memanggil metode GetAllPropertyItems dari objek Gambar 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 data member 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 nomor ID heksadesimal untuk setiap item properti. Anda dapat mencari nomor ID tersebut di Gdiplusimaging.h dan mencari tahu bahwa nomor 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
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk