L_WriteFileTag

#include "l_bitmap.h"

L_LTFIL_API L_INT L_WriteFileTag(pszFile, pSaveOptions)

L_TCHAR* pszFile;

/* filename */

pSAVEFILEOPTION pSaveOptions;

/* pointer to optional extended save options */

Writes tags to a file or changes existing tags in a file.

Parameter

Description

pszFile

Character string that contains the filename.

pSaveOptions

Pointer to optional extended save options. Pass NULL to use the default save options. pSaveOptions.PageNumber indicates the page on which to write the tags. Note that an error code will be returned if the page does not exist.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function writes tags into an existing file or changes tags in an existing file.

This function will write all the tags that have been set using L_SetTag. There must be at least one tag set for this function to work. If no tags have been set, an error will be returned by this function.

This function works only with TIFF files.

Some restrictions apply to this function if you use an IFD to indicate to which page to write the tags. See the Loading and Saving Large TIFF Files topic for more information.

Note:

Use this function carefully. LEADTOOLS will not restrict the tags that you write. If you write bad tags, the file might become corrupted. Consult the TIFF documentation for a list of predefined tags. It is recommended that you write only the user-defined tags (the tags between 0x8000 and 0xFFFF).

 

See the TIFF documentation for a complete list of the TIFF tags and types.

When you add or remove comments or tags, the comments and tags array at the end of the TIFF/Exif image file is re-written. When you modify existing comments or tags, the new value is added to the file and the IFD is modified as necessary. In all of these cases, there is no image recompression.

Required DLLs and Libraries

LTFIL

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_SetTag, L_GetTag, SAVEFILEOPTION, L_SaveFile, L_SaveBitmap, L_ReadFileTag, L_WriteFileMetaData, L_DeleteTag, L_ReadFileTags

Topics:

Raster Image Functions: Input and Output

 

Loading and Saving Images

Example

 L_INT WriteFileTagExample()
{
   L_INT nRet;
   L_UINT16 LogoPosition = 0x8001; /* my private tag      */
   L_UINT16 TagType = TAG_SHORT;   /* tagged data type    */
   L_UINT32 TagCount = 4;          /* count of data items */
   L_INT16  TagData[] = {5, 5, 24, 37};
   L_VOID* pTagData = &TagData;   /* pointer to the buffer containing the data */
   SAVEFILEOPTION  SaveFileOption;
   /* Set the tag data to be saved */
   nRet = L_SetTag(LogoPosition, TagType, TagCount, pTagData);
   if(nRet < SUCCESS)
      return nRet;
   nRet = L_GetDefaultSaveFileOption(&SaveFileOption, sizeof(SAVEFILEOPTION));
   if(nRet != SUCCESS)
      return nRet;
   SaveFileOption.PageNumber = 1;
   /* Save the file with the tag.  Note that TEST.TIF must exist and contain at least one page! */
   nRet = L_WriteFileTag(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\TEST.TIF"), &SaveFileOption);
   if(nRet != SUCCESS)
      return nRet;
   /* Clear the tag from memory */
   nRet = L_SetTag(0, 0, 0, NULL);
   return SUCCESS;
}