L_DocWriterUpdateMetaFileResolution

#include "l_bitmap.h"

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

L_HENHMETAFILE hEmfSrc;

/* handle to the source EMF */

L_UINT xResolution;

/* new X resolution */

L_UINT yResolution;

/* new Y resolution */

L_VOID * pDocOptions;

/* pointer to a Document Options structure */

L_HENHMETAFILE * phEmfDest;

/* address of a variable to be updated */

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

Parameter

Description

hEmfSrc

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

xResolution

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

yResolution

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

phEmfDest

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

Returns

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

LtDocWrt_u.dll, LtDocWrt_x.dll
LtFil_u.dll, LtFil_x.dll
LfJb2_u.dll, LfJb2_x.dll
Lfcmp_u.dll, Lfcmp_x.dll
Lftif_u.dll, Lftif_x.dll
Lfraw_u.dll, Lfraw_x.dll
Lfbmp_u.dll, Lfbmp_x.dll
Lfpng_u.dll, Lfpng_x.dll
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP / Vista.

See Also

Functions:

L_DocWriterInit

Topics:

Creating Document Formats

 

Raster Image Functions: Document Writers

Example

This example converts Lead document format (ltd) to MS Word document foramt (doc)

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);

   GetEnhMetaFileHeader(hEmf, uSize, pHeader);
   wprintf(L"Size: %d by %d pixels\n", pHeader->rclBounds.right - pHeader->rclBounds.left, pHeader->rclBounds.bottom - pHeader->rclBounds.top);

   // 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);
   wprintf(L"Resolution: %d by %d pixels/inch\n", xResolution, yResolution);

   free(ptr);
}


L_LTDOCWRTTEX_API L_INT L_DocWriterUpdateMetaFileResolutionExample(L_VOID)
{
   // Load the original meta file
   L_HENHMETAFILE hEmf = GetEnhMetaFile(L"C:\\Users\\Public\\Documents\\LEADTOOLS Images\\Ocr1.emf");

   // Show the dimension
   wprintf(L"Original EMF dimension:\n");
   ShowMetaFileDimension(hEmf);

   // Change the resolution to be 200 by 200 dots/inch
   L_HENHMETAFILE hEmfDest = NULL;
   L_INT nRet = L_DocWriterUpdateMetaFileResolution(hEmf, 200, 200, &hEmfDest);

   // No need for the original handle anymore
   DeleteEnhMetaFile(hEmf);

   if(nRet == SUCCESS)
   {
      wprintf(L"New EMF dimension:\n");
      ShowMetaFileDimension(hEmfDest);
      DeleteEnhMetaFile(hEmfDest);
   }

   return SUCCESS;
}