Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LFileSettings::SetWMFResolution
#include "ltwrappr.h"
static L_INT LFileSettings::SetWMFResolution (nXResolution=0, nYResolution=0)
L_INT nXResolution; |
/* the horizontal resolution value */ |
L_INT nYResolution; |
/* the vertical resolution value */ |
Sets the DPI (dots per inch) value that LEADTOOLS uses when loading WMF/EMF files.
Parameter |
Description |
|
nXResolution |
Value that represents the horizontal resolution that LEADTOOLS uses when loading images from WMF files. Possible values are: |
|
|
Value |
Meaning |
|
0 |
Load the file at the resolution present in the file. This is the default value. This is the default value. |
|
Any positive value |
Load the file at the corresponding DPI. For example, if this value is 150, load the image at 150 DPI. |
nYResolution |
Value that represents the vertical resolution that LEADTOOLS uses when loading images from WMF files. Possible values are: |
|
|
Value |
Meaning |
|
0 |
Load the file at the resolution present in the file. This is the default value. This is the default value. |
|
Any positive value |
Load the file at the corresponding DPI. For example, if this value is 150, load the image at 150 DPI. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The values that this function sets are valid for the current thread, and you can change the values in the thread only by calling this function again.
The 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 rises mainly when loading vectored graphics.
LEADTOOLS loads a WMF/EMF 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 smaller 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 LFileSettings::GetWMFResolution and LFileSettings::SetWMFResolution functions, along with the LFile::GetInfo or LMemoryFile::GetInfo function, to manage these image size issues. The following are examples of how you can use these functions:
To load an image at its saved resolution, you can do the following:
1. |
Call LFileSettings::SetWMFResolution function with nXResolution and nYResolution parameters set to 0. |
2. |
Call LFile::Load function 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. |
Call LFileSettings::SetWMFResolution function with nXResolution and nYResolution set to 0. |
2. |
Call LFile::GetInfo function, and in the FILEINFO structure, check the XResolution and Width values 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 FILEINFO structure XResolution is B, the desired width is C, and the value of the FILEINFO.Width field is D, the calculation is as follows: A = B * C / D. |
4. |
Call LFileSettings::SetWMFResolution function to set the desired resolution. |
5. |
Call LFile::Load function to load the file. |
Some WMF/EMF 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 LFileSettings::SetWMFResolution function has no effect.
Note: |
When saving WMF/EMF files, LEADTOOLS saves the current resolution value in the file. |
Note: |
More options are available in the LOADFILEOPTION structure. |
Required DLLs and Libraries
LTFIL For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64.
See Also
Example
L_INT LFileSettings__SetWMFResolutionExample() { L_INT nRet; //... LFileSettings fileSettings; nRet = fileSettings.SetWMFResolution(150,0); if(nRet != SUCCESS) return nRet; return SUCCESS; }