Método Image::SetPropertyItem (gdiplusheaders.h)

El método Image::SetPropertyItem establece un elemento de propiedad (fragmento de metadatos) para este objeto Image . Si el elemento ya existe, se actualiza su contenido; de lo contrario, se agrega un nuevo elemento.

Sintaxis

Status SetPropertyItem(
  [in] const PropertyItem *item
);

Parámetros

[in] item

Tipo: const PropertyItem*

Puntero a un objeto PropertyItem que especifica el elemento de propiedad que se va a establecer.

Valor devuelto

Tipo: Estado

Si el método se ejecuta correctamente, devuelve Ok, que es un elemento de la enumeración Status .

Si se produce un error en el método, devuelve uno de los otros elementos de la enumeración Status .

Comentarios

Algunos formatos de imagen (por ejemplo, ICON y EMF) no admiten propiedades. Si llama al método Image::SetPropertyItem en una imagen que no admite propiedades, devolverá PropertyNotSupported.

Ejemplos

La siguiente aplicación de consola crea un objeto Image basado en un archivo JPEG. El código llama al método Image::SetPropertyItem de ese objeto Image para establecer el título de la imagen. A continuación, el código recupera y muestra el nuevo título.

#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");

   // Set the image title.
   PropertyItem* propItem = new PropertyItem;
   CHAR newTitleValue[] = "Fake Photograph 2";

   propItem->id = PropertyTagImageTitle;
   propItem->length = 18;  //  includes null terminator
   propItem->type = PropertyTagTypeASCII;
   propItem->value = newTitleValue;

   image->SetPropertyItem(propItem);

   // Get and display the new image title.
   UINT size = image->GetPropertyItemSize(PropertyTagImageTitle);
   PropertyItem* title = (PropertyItem*)malloc(size);
   image->GetPropertyItem(PropertyTagImageTitle, size, title);
   printf("The image title is %s.\n", title->value);

   free(title);
   delete propItem;
   delete image;
   GdiplusShutdown(gdiplusToken);
   return 0;
}

Requisitos

Requisito Value
Cliente mínimo compatible Windows XP, Windows 2000 Professional [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows 2000 Server [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
Archivo DLL Gdiplus.dll

Consulte también

Imagen

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

PropertyItem

Lectura y escritura de metadatos