WMFResolutionX property (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int WMFResolutionX

Delphi Syntax

WMFResolutionX : L_INT

Overview

Refer to Loading a Bitmap from a File.

Remarks

Gets or sets the current horizontal resolution value that LEADTOOLS uses when loading images from WMF/EMF files. Possible values are:

Value

Meaning

0

Load the file at the resolution present in the file.

Any positive value

Load the file at the corresponding DPI. For example, if this value is 150, load the image at 150 DPI.

WMF files can contain vectored graphics or raster images. LEADTOOLS can load either type, but can save only raster images. The issue of image resolution arises mainly when loading vectored graphics.

LEADTOOLS loads a WMF file by creating a temporary device context (DC), drawing the vectored graphics (or painting the raster image) in the device context, and converting the resulting device context to a bitmap. Loading an image at some DPI values may yield an image that is smaller, and less detailed, than the original, or, since bitmaps use more memory than vectored graphics, it may yield an image that is too large to handle efficiently.

You can use the InfoXRes, InfoYRes, WMFResolutionX, and WMFResolutionY properties along with GetFileInfo, to manage these image size issues. The following are examples of how you can use these methods:

To load an image at its saved resolution, you can do the following:

1.

Set WMFResolutionX and WMFResolutionY to 0.

2.

Call the Load method to load the file.

To load an image that will fit a predetermined width (such as the width of your application's client area), you can do the following:

1.

Set WMFResolutionX and WMFResolutionY to 0.

2.

Call GetFileInfo and check the InfoXRes property and the InfoWidth property, to determine the resolution and size of the image stored in the file.

3.

Calculate the necessary resolution to get the desired width. Where the necessary resolution is A, the value from the InfoXRes property is B, the desired width is C, and the value of the Width field is D, the calculation is as follows: A = B * C / D.

4.

Set WMFResolutionX and WMFResolutionY to the desired resolution.

5.

Call Load to load the file.

Some WMF files contain viewport information, which requires a device context of a particular size. LEADTOOLS always loads these files using the resolution specified in the file. In this case, the value specified by WMFResolutionX and WMFResolutionY has no effect.

Note:

When saving WMF files, LEADTOOLS saves the current resolution value in the file.

See Also

Elements:

GetFileInfo method, InfoXRes property, InfoYRes property, WMFResolutionY property

Topics:

Raster Images: Loading Files