L_LTFIL_API L_INT L_TransformFile(pszFileSrc, pszFileDst, uTransform, pfnCallback, pUserData, pLoadOptions)
Performs a lossless transformation for certain formats. Currently, only JPEG, CMP, TIFF and HEIF/HEIC formats are supported.
Character string containing the name of the source file.
Character string containing the name of the destination file.
Binary flags that indicate the transform to be performed. Possible values are:
|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.|
Optional callback function for processing custom markers. (This is useful for rotating JPEG files only). When transforming JPEG files, the function 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.
If you do not provide a callback function, use NULL as the value of this parameter and no JPEG markers will be transformed.
If you do provide a callback function, use the function pointer as the value of this parameter.
The callback function must adhere to the function prototype described in TRANSFORMFILECALLBACK Function.
Void pointer that you can use to pass one or more additional parameters that the callback 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 pUserData 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.
Pointer to optional extended load options. Pass NULL to use the default load options (first page). This is useful only for transforming TIFF and HEIF/HEIC files.
The load options will specify which page should be transformed.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
Only one of the rotate flags can be specified.
The files transformed by this function will be read transformed by other applications capable of reading these file formats.
JPEG and Exif JPEG stamps are transformed according to the flags specified in
uTransform. Please note that some JPEG stamps will not be transformed by this function. Specifically, stamps stored in markers other than APP0 and APP1 will not be transformed. Use the TRANSFORMFILECALLBACK function to handle these cases. For example, if a stamp is in the APP14 marker, check for this in the TRANSFORMFILECALLBACK function and write your own stamp using L_WriteFileStamp.
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 fast and lossless. It is better than loading the image, transforming it using L_RotateBitmap, L_FlipBitmap or L_ReverseBitmap and resaving it. Repeated load and save process will be slow and cause image degradation, but calling this function will be fast and not cause any image degradation.
The rotation transformations are performed before the flip/reverse operations.
Required DLLs and Libraries
Win32, x64, Linux.
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, NULL, NULL, NULL);
if(nRet != SUCCESS)
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries