L_DocWriterUpdateMetaFileResolution

Summary

Changes the resolution of an existing Enhanced Metafile (EMF).

Syntax

#include "l_bitmap.h"

L_LTDOCWRT_API L_INT EXT_FUNCTION L_DocWriterUpdateMetaFileResolution (hEmfSrc, xResolution, yResolution, phEmfDest)

Parameters

L_HENHMETAFILE hEmfSrc

Handle to the Enhanced Metafile (EMF) to be updated.

L_INT xResolution

The new X Resolution value. 0 means do not change this resolution.

L_INT yResolution

The new Y Resolution value. 0 means do not change this resolution.

L_HENHMETAFILE * phEmfDest

Address of an Enhanced Metafile (EMF) handle that will be updated with the modified EMF.

Returns

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

Comments

A value of 0 for xResolution or yResolution means do not change this resolution value. This allows you to only change the horizontal or the vertical resolution of an Enhanced Metafile (EMF) handle without affecting the other resolution.

If either xResolution or yResolution is equal to -1, then the aspect ratio for the original EMF handle will be maintained and the positive value for either xResolution or yResolution will be used as the resolution (DPI) value for the modified EMF handle. Note that xResolution and yResolution cannot both be less than zero.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

static void ShowMetaFileDimension(HENHMETAFILE hEmf) 
{ 
   // Get the metafile header 
   L_UINT uSize = GetEnhMetaFileHeader(hEmf, 0, NULL); 
   L_VOID* ptr = malloc(uSize); 
   ENHMETAHEADER* pHeader = reinterpret_cast<ENHMETAHEADER*>(ptr); 
 
   L_TCHAR szBuffer[_MAX_PATH]; 
   wsprintf(szBuffer, "Meta Information. Size: %d by %d pixels\n", pHeader->rclBounds.right - pHeader->rclBounds.left, pHeader->rclBounds.bottom - pHeader->rclBounds.top); 
   _tprintf(_T("%s"), szBuffer); 
 
   // The resolution is saved in 0.01 mm units, convert to dots/inch 
   L_INT xResolution = (L_INT)((L_DOUBLE)pHeader->szlDevice.cx * 25.4 / (L_DOUBLE)pHeader->szlMillimeters.cx + 0.5); 
   L_INT yResolution = (L_INT)((L_DOUBLE)pHeader->szlDevice.cy * 25.4 / (L_DOUBLE)pHeader->szlMillimeters.cy + 0.5); 
   wsprintf(szBuffer, "Meta Information. Resolution: %d by %d pixels/inch\n", xResolution, yResolution); 
   _tprintf(_T("%s"), szBuffer); 
 
   free(ptr); 
} 
 
L_INT L_DocWriterUpdateMetaFileResolutionExample(L_VOID) 
{ 
   // Load the original meta file 
   L_HENHMETAFILE hEmf = GetEnhMetaFile(MAKE_IMAGE_PATH("Ocr1.emf")); 
 
   // Show the dimension 
   L_TCHAR szBuffer[_MAX_PATH]; 
   wsprintf(szBuffer, "Meta Information: Original EMF dimension:\n"); 
   _tprintf(_T("%s"), szBuffer); 
   ShowMetaFileDimension(hEmf); 
 
   // Change the resolution to be 200 by 200 dots/inch 
   L_HENHMETAFILE hEmfDest = NULL; 
   L_INT nRet = L_DocWriterUpdateMetaFileResolution(hEmf, 600, 600, &hEmfDest); 
 
   // No need for the original handle anymore 
   DeleteEnhMetaFile(hEmf); 
 
   if (nRet == SUCCESS) 
   { 
      wsprintf(szBuffer, "Meta Information: New EMF dimension:\n"); 
      _tprintf(_T("%s"), szBuffer); 
      ShowMetaFileDimension(hEmfDest); 
      DeleteEnhMetaFile(hEmfDest); 
   } 
 
   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 API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.