The following example creates an Image object based on a JPEG file. The code removes the
PropertyTagImageTitle property item from the Image object by calling the
GdipRemovePropertyItem function. The code calls
GdipGetPropertyItemSize twice (once before and once after removing the item) to determine the size of the
PropertyTagImageTitle property item. The code does not remove the property item from the image file; it removes the property item only from the Image object. To save the image (with the property item removed) to a new JPEG file, call the
GdipSaveImageToFile function.
C++
#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;
}
PowerBASIC
#COMPILE EXE
#DIM ALL
#INCLUDE "GDIPLUS.INC"
' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN
LOCAL hStatus AS LONG
LOCAL token AS DWORD
LOCAL StartupInput AS GdiplusStartupInput
LOCAL pImage AS DWORD
LOCAL strFileName AS STRING
LOCAL nSize AS DWORD
' // Initialize GDI+
StartupInput.GdiplusVersion = 1
hStatus = GdiplusStartup(token, StartupInput, BYVAL %NULL)
IF hStatus THEN
PRINT "Error initializing GDI+"
EXIT FUNCTION
END IF
strFileName = UCODE$("BERRY_Halle_Modified.jpg")
hStatus = GdipLoadImageFromFile(STRPTR(strFileName), pImage)
' // Get the size of the image title
hStatus = GdipGetPropertyItemSize(pImage, %PropertyTagImageTitle, nSize)
PRINT "The size of the title is" & STR$(nSize) & " bytes."
' // Remove the title property.
hStatus = GdipRemovePropertyItem(pImage, %PropertyTagImageTitle)
' // Get the size of the image title
nSize = 0
hStatus = GdipGetPropertyItemSize(pImage, %PropertyTagImageTitle, nSize)
PRINT "The size of the title is" & STR$(nSize) & " bytes."
' // Cleanup
IF pImage THEN GdipDisposeImage(pImage)
' // Shutdown GDI+
GdiplusShutdown token
WAITKEY$
END FUNCTION
' ========================================================================================