ImageGear for C and C++ on Windows v20.0 - Updated
LPFNIG_TAG_GET
API Reference Guide > Core Component API Reference > Core Component Callback Functions Reference > LPFNIG_TAG_GET

This function has been deprecated and will be removed from the public API in a future release. Please use LPAFT_IG_METAD_ITEM_ADD_CB instead.

Declaration:

 
Copy Code
typedef BOOL (ACCUAPI LPFNIG_TAG_GET) (
        LPVOID lpPrivate, 
        AT_MODE nIGTag, 
        LPAT_MODE lpDataType, 
        LPVOID lpTagData, 
        DWORD dwSize 
);

Arguments:

Name Type Description
lpPrivate LPVOID A far pointer to a private data area that can be used for anything you like. For example, you might store the HIGEAR handle of the image that is being loaded.
nIGTag AT_MODE ImageGear supplies you with an IGTAG_ Tag ID constant from file Geartags.h, so that you will know which tag is currently being saved.
lpDataType LPAT_MODE ImageGear supplies you with an IG_TAG_TYPE_ constant from file accucnst.h, specifying the data type for this tag (e.g., BYTE, LONG, FLOAT, etc.).
lpTagData LPVOID ImageGear supplies you with this pointer to a buffer, where you should store your data. If you read this field, you will find that it contains a default value. For example, the ImageGear default value for the Artist tag is "1996-2014 Accusoft Inc., All rights reserved."
dwSize DWORD ImageGear tells you the size of tag data buffer, in bytes. This is your limit for the length of what you store to lpTagData.

Return Value:

Returns TRUE if ImageGear should overwrite the default tag data with your data, or FALSE if ImageGear should ignore your data.

Supported Raster Image Formats:

This function does not process image pixels.

Sample:

JPEG, Filters, FlashPix

Example:

 
Copy Code
BOOL ACCUAPI TagGet(
   LPVOID         lpPrivate,     /* Private data passed in        */
   AT_MODE        nIGTag,        /* Tag ID from geartags.h        */
   LPAT_MODE      lpType,        /* Type of data lpTag points to  */
   LPBYTE         lpTag,         /* Pointer to tag data           */
   DWORD          dwSize         /* Size of tag data (bytes)      */
   )
...
return TRUE; /* FALSE to terminate the save operation */ 
}
...
   IG_save_tag_CB_register( TagGet, TagUserGet, (LPVOID)&dwPrivateFlags );
/* The following example may be used for writing additional information into a GIF file: */
BOOL ACCUAPI GifCallbackTagGet(
        LPVOID  lpPrivate,
        AT_MODE         nIGTag,
        LPAT_MODE       lpType,
        LPVOID  lpData,
        DWORD   dwSize
        )
{
        LPBYTE  lpRGB;
        static INT i=0;
        switch(nIGTag)
        {
                case IGTAG_GIF_SCREEN_WIDTH:
                        *(LPWORD)lpData=777;
                        break;
                case IGTAG_GIF_SCREEN_FLAGS:
                        *(LPBYTE)lpData=0x80 | 0x07;
                        break;
                case IGTAG_GIF_IMAGE_FLAGS:
                        *(LPBYTE)lpData=0x80 | 0x07;
                        break;
                case IGTAG_GIF_IMAGE_LEFT:
                        *(LPWORD)lpData=111;
                        break;
                case IGTAG_GIF_SCREEN_PALETTE:
                        lpRGB=(LPBYTE)lpData;
                        for(i=0; i<256; i++)
                        {
                                lpRGB[3*i]=(BYTE)(0);
                                lpRGB[3*i+1]=(BYTE)(i);
                                lpRGB[3*i+2]=(BYTE)(0);
                        }
                        break;
                case IGTAG_GIF_IMAGE_PALETTE:
                        lpRGB=(LPBYTE)lpData;
                        for(i=0; i<256; i++)
                        {
                                lpRGB[3*i]=(BYTE)i;
                                lpRGB[3*i+1]=(BYTE)(0);
                                lpRGB[3*i+2]=(BYTE)(0);
                        }
                        break;
                case IGTAG_GIF_EXT_NUMBER_BEFORE_IMG:
                        *(LPWORD)lpData=4;
                        break;
                case IGTAG_GIF_EXT_BEFORE_IMG:
                        switch(i++%4)
                        {
                                case 0:
                                        CtrlExt.bLabel=CTRL_EXT_LABLE;
                                        CtrlExt.bPacked=249;
                                                                {
                                case 0:
                                        CtrlExt.bLabel=CTRL_EXT_LABEL;
                                        CtrlExt.bPacked=249;
                                        CtrlExt.wDelayTime=555;
                                        CtrlExt.bColorIndex=111;
                                        *(LPVOID FAR*)lpData=(LPVOID)&CtrlExt;
                                        break;
                                case 1:
                                        TextExt.bLabel=TEXT_EXT_LABEL;
                                        TextExt.wTextGridLeft=333;
                                        TextExt.lpData=lpStr;
                                        *(LPVOID FAR*)lpData=(LPVOID)&TextExt;
                                        break;
                                case 2:
                                        CommExt.bLabel=COMM_EXT_LABEL;
                                        CommExt.lpData=lpStr;
                                        *(LPVOID FAR*)lpData=(LPVOID)&CommExt;
                                        break;
                                case 3:
                                        ApplExt.bLabel=APPL_EXT_LABEL;
                                        strcpy((CHAR*)ApplExt.Identifier, 
                                                "Accusoft");
                                        strcpy((CHAR*)ApplExt.AuthentCode, "6.0");
                                        ApplExt.lpData=lpStr;
                                        *(LPVOID FAR*)lpData=(LPVOID)&ApplExt;
                                        break;
                        }
                        break;
        }
        return TRUE

Remarks:

This function will be called once for each "non-volatile" tag that is being written.

This callback function is registered by calling IG_save_tag_CB_register(). When ImageGear is going to perform any save operation it will first check to see if you have registered any applicable callbacks. If you have registered a callback of type LPFNIG_TAG_GET, it will be called once for each "non-volatile" tag that is being written. ImageGear will not call your callback for what it terms "volatile" tags, so that you are unable to modify such tags. If you are writing a TIFF file and want to determine which tags you can write to (that is, which tags are non-volatile), please see the TIFF tags section of Geartags.h. This section is comprised of a list of constants for all registered TIFF tags and a 5-column key that gives you information about the read and write ability of each tag.

See also the Note under TIFF File Format Reference for an explanation of how to use the key.

While you may set the data of a non-volatile tag, your data must not exceed the length specified by dwSize. You must also use the proper data type, which you can check by reading the lpDataType parameter.

Your callback could contain a switch statement for each tag to which you would like to write. Each case in the switch statement could check the ImageGear default setting of the tag and decide whether to change the data. Set your callback to TRUE if you want ImageGear to overwrite the data of a tag, FALSE if you want it to ignore your data. When you set the callback to FALSE, ImageGear will use its own default value for the current tag, but will still call your callback when it parses the next tag.

Note also that some tags can be set only to a certain range of valid values. If your data is out of range for such tags, ImageGear will ignore your data.

If you would like to modify tag data as the image is being read in (for instance, you want it to be modified for display purposes), register a callback of type LPFNIG_TAG_SET.

If you would like to add your own user-defined tags to a TIFF file, register a callback of type LPFNIG_TAG_USER_GET. Your tags will be saved with the image when it is being saved.

See also the discussion about Tag Callbacks in the section Working with ImageGear Callback Functions.

Is this page helpful?
Yes No
Thanks for your feedback.