Image::RemovePropertyItem 方法 (gdiplusheaders.h)

Image::RemovePropertyItem 方法从此 Image 对象中删除属性项 (元数据) 。

语法

Status RemovePropertyItem(
  [in] PROPID propId
);

parameters

[in] propId

类型: PROPID

用于标识要删除的属性项的整数。

返回值

类型: 状态

如果方法成功,则返回 Ok,这是 Status 枚举的元素。

如果 方法失败,它将返回 Status 枚举的其他元素之一。

注解

Image::RemovePropertyItem 方法从 Image 对象中删除指定的属性,但该属性项不会从用于构造 Image 对象的文件或流中删除。 若要将图像 () 删除的属性项保存到新的 JPEG 文件或流中,请调用 Image 对象的 Save 方法。

示例

以下示例基于 JPEG 文件创建 Image 对象。 代码通过调用 Image 对象的 Image::RemovePropertyItem 方法从 Image 对象中删除 PropertyTagEquipMake 属性项。 该代码调用 Image::GetPropertyItemSize (之前和删除项后两次) ,以确定 PropertyTagEquipMake 属性项的大小。 代码不会从图像文件中删除属性项;它仅从 Image 对象中删除属性项。

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

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

   Image* image = new Image(L"FakePhoto3.jpg");
   UINT size = 0;

   size = image->GetPropertyItemSize(PropertyTagEquipMake);
   printf("The size of the PropertyTagEquipMake item is %u.\n", size);

   image->RemovePropertyItem(PropertyTagEquipMake);   

   size = image->GetPropertyItemSize(PropertyTagEquipMake);
   printf("The size of the PropertyTagEquipMake item is %u.\n", size);

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

前面的代码以及特定文件 FakePhoto3.jpg 生成了以下输出:

The size of the PropertyTagEquipMake item is 33.
The size of the PropertyTagEquipMake item is 0.

要求

   
最低受支持的客户端 Windows XP、Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器 Windows 2000 Server [仅限桌面应用]
目标平台 Windows
标头 gdiplusheaders.h (包括 Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

另请参阅

图像

Image::GetAllPropertyItems

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertyItemSize

Image::GetPropertySize

Image::SetPropertyItem

PropertyItem

读取和写入元数据