TRANSFORMFILECALLBACK

#include "l_bitmap.h"

L_INT pEXT_CALLBACK YourFunction (uMarker, uMarkerSize, pMarkerData, pUserData, uTransform, pfnLEADCallback, pLEADUserData)

Handles the processing of every JPEG marker present in the file transformed by L_TransformFile.

Parameters

L_UINT uMarker

ID of the JPEG marker. The JPEG markers are uniquely identified by a byte value. Possible values are 1 to 254. (0 and 255 are not allowed.)

L_UINT uMarkerSize

Size of the JPEG marker. The size will be less than 65535. If this value is 0, then the marker does not have any extra data.

L_UCHAR* pMarkerData

Pointer to a buffer containing the marker data. This parameter is valid only if the uMarkerSize is > 0.

L_VOID* pUserData

A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of the calling function.)

Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

L_UINT uTransform

Binary flags that indicate the transform to be performed. These are the same flags passed to the L_TransformFile function. Possible values are:

Value Meaning
FILE_TRANSFORM_FLIP [0x0001] Flip the image.
FILE_TRANSFORM_REVERSE [0x0002] Reverse the image.
FILE_TRANSFORM_ROTATE90 [0x0004] Rotate the image clockwise by 90 degrees.
FILE_TRANSFORM_ROTATE180 [0x0008] Rotate the image clockwise by 180 degrees.
FILE_TRANSFORM_ROTATE270 [0x000C] Rotate the image clockwise by 270 degrees.

LEADMARKERCALLBACK pfnLEADCallback

Pointer to a callback function, provided by LEADTOOLS, for writing transformed markers.

The callback function adheres to the function prototype described in LEADMARKERCALLBACK Function.

L_VOID* pLEADUserData

Void pointer that you can use to pass one or more additional parameters that the LEADMARKERCALLBACK function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pLEADUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

Value Meaning
SUCCESS The function was successful. The default processing for this marker can be performed.
SUCCESS_IGNOREMARKER The function was successful. Do not process this marker and do not write it to the file.
< 1 An error occurred. Refer to Return Codes.

Comments

This callback function is called by the L_TransformFile function.

This callback can also be used to enumerate the markers in a JPEG file. The last marker enumerated by this function is always the SOS (0xDA) marker.

If the marker data is transformed, make sure the size of the marker data is less than 0xFFFE.

Note that uMarkerSize is the size of the data contained in the pMarkerData buffer. It does not include the size of the marker size (like the size stored in the file). If you are not familiar with JPEG markers and the previous did not make sense to you, then you can safely ignore this paragraph.

If the marker data is transformed, it should be written by calling the pfnLEADCallback function. Then, SUCCESS_IGNOREMARKER should be returned by the TRANSFORMFILECALLBACK function. If SUCCESS is returned by the TRANSFORMFILECALLBACK function instead of SUCCESS_IGNOREMARKER, LEADTOOLS will perform the default transformation and will also write this marker information to the file. Therefore, there will be two copies of the marker in the file.

As an example, if a user-defined marker that contains a stamp of the image is stored in a file and that file is transformed, the stamp should be transformed in the same way and resaved.

If this function returns an error code, the transformation is aborted and L_TransformFile will return the error code returned by this callback function.

Required DLLs and Libraries

See Also

Functions

Topics

Example

For an example, refer to L_StartCompressBuffer.
For complete sample code, refer to the COMPCB example.

#define APP0 0xE0 
 
L_INT EXT_CALLBACK MyRotateMarker( 
   L_UINT uMarker, 
   L_UINT uMarkerSize, 
   L_UCHAR* pMarkerData, 
   L_VOID* pUserData, 
   L_UINT uTransform, 
   LEADMARKERCALLBACK pfnLEADCallback, 
   L_VOID* pLEADUserData) 
{ 
   UNREFERENCED_PARAMETER(uTransform); 
   UNREFERENCED_PARAMETER(pUserData); 
    
    L_INT nRet; 
    /* I will transform only the APP0 marker  */ 
    if (uMarker != APP0) 
       return SUCCESS; 
    /* Transform the marker data. Do your transformation here... */ 
    /* write the transformed data */ 
    nRet  = pfnLEADCallback(uMarker, uMarkerSize, pMarkerData, pLEADUserData); 
    if (nRet != SUCCESS) 
       return nRet; 
    /* since I wrote the marker, tell LEADTOOLS not to transform it */ 
    return SUCCESS_IGNOREMARKER; 
} 
 
L_INT TransformfileCallbackExample() 
{ 
   L_INT nRet; 
    /* This example rotates the file by 90 degrees */ 
    nRet = L_TransformFile (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image1.jpg")),MAKE_IMAGE_PATH(TEXT("Transformed.JPG")), FILE_TRANSFORM_ROTATE90,MyRotateMarker, NULL, NULL); 
 
    return nRet; 
} 

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.