Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Metode Image::GetPropertyItemSize mendapatkan ukuran, dalam byte, dari item properti tertentu dari objek Gambar ini.
Sintaks
UINT GetPropertyItemSize(
[in] PROPID propId
);
Parameter
[in] propId
Jenis: PROPID
Bilangan bulat yang mengidentifikasi item properti.
Menampilkan nilai
Jenis: UINT
Metode ini mengembalikan ukuran, dalam byte, dari item properti tertentu dari objek Gambar ini.
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 memanggil metode Image::GetPropertyItemSize dari objek Image tersebut untuk mendapatkan ukuran item properti yang menyimpan pembuatan kamera yang digunakan untuk mengambil gambar. Kemudian kode memanggil metode Image::GetPropertyItem untuk mengambil item properti tersebut.
#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, yang merupakan 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
| 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 |