Performs a lossless transformation for certain formats. The specified file is the destination file, while the internal file used by the class object is the source file. Currently, only JPEG, CMP, JPEG TIFF and HEIF/HEIC formats are supported.


#include "ltwrappr.h"

virtual L_INT LFile::TransformFile(pszFileDst, uTransform, pLoadOptions=NULL)


L_TCHAR * pszFileDst

Character string containing the name of the destination file.

L_UINT uTransform

Binary flags that indicate the transform to be performed. 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.


Pointer to optional extended load options. Pass NULL to use the default load options. This is useful only for transforming TIFF and HEIF/HEIC files. The load options will specify the page to transform.


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


Only one of the rotate flags can be specified.

This function calls the LFile:TransformFileCallBack, if the callback function has been enabled by calling the LBase::EnableCallBack. The callback function is provided for processing custom markers. (This is useful for rotating JPEG files only.) When transforming JPEG files, LFile::TransformFile will enumerate all the markers contained in the file and it will pass them to this callback. The user has the ability to control the transformation for all the markers. For additional information on JPEG markers, please consult the JPEG specification.

To customize this callback, derive a new class from LFile and override LFile::TransformFileCallBack, providing the needed functionality. (Create the object from the new class.)

The files transformed by this function will be read transformed by other applications capable of reading these file formats.

For JPEG files, the size of the image might be changed. The image width and height is adjusted to be a multiple of 8 or 16 depending on the subsampling present in the image. If the image is 4:4:4, the width and height is adjusted to be a multiple of 16. If the image is 422, the original width is adjusted to be a multiple of 16 and the height to be a multiple of 8. After rotation, the width might become height. If the image is 411, the width and height are adjusted to be a multiple of 16.

The transformation is lossless. It is better than loading the image, transforming it using LBitmapBase::Rotate, LBitmapBase::Flip or LBitmapBase::Reverse and resaving it. Repeated load and save process will cause image degradation, but calling this function will not cause any image degradation.

The rotation transformations are performed before the flip/reverse operations.

Required DLLs and Libraries


Win32, x64.

See Also




L_INT LFile__TransformFileExample(L_TCHAR * pszFileSrc, L_TCHAR * pszFileDst) 
   L_INT nRet; 
   LFile File; 
   nRet = File.TransformFile(pszFileDst, FILE_TRANSFORM_ROTATE90); 
   if(nRet != SUCCESS) 
      return nRet; 
   return SUCCESS; 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help