One of the major features of WPF is resolution independence. All visual objects are positioned and measured using device independent coordinates. This is different from GDI+ and Silverlight environments, which measure graphic objects in pixels.
WPF defines one device independent unit as 1/96th of an inch. One unit maps to one pixel if the system uses 96 dpi display setting (Windows Small Fonts).
Most of ImageGear display API supports both GDI+ and WPF. However, the ImageGear term "Device Coordinates" has different meaning in GDI+ and WPF. In GDI+, device coordinates are pixels, and in WPF they are WPF device independent units, rounded to an integer.
This affects the following API:
Device Resolutions
ImageGear renders images according to the specified device dimensions. In WPF, device dimensions are specified in device-independent units. If an end user uses the standard Windows display resolution of 96 DPI ("Small Fonts"), one device independent unit maps exactly to one pixel. In other words, if you set the device rectangle to 100x100, then the size of the ImageGear rendered image will be 100x100 pixels, and the image will occupy an area of 100x100 pixels on the screen.
If the display resolution is different from the default 96 DPI, or when printing an image, the device independent units do not map exactly to device units. For example, if you set the device rectangle to 100x100, and print on a 600 DPI printer, the size of the ImageGear rendered image will still be 100x100 pixels, but the WPF engine will stretch it onto a 625x625 pixel area on the printer (100 / 96 * 600 = 625). This may result in a blurry, low-resolution appearance.
ImageGear provides two ways to avoid this scaling issue:
- Pass the device resolution info to the drawing functions to render the image according to the actual device resolution. For example, if you set the device rectangle to 100x100, print on a 600 DPI printer, and pass the resolution info to the drawing method, the size of the ImageGear rendered image will be 625x625 pixels, and the image will occupy a 625x625 pixel area on the printer. This avoids scaling by the WPF engine.
- Use the WPF engine to scale images. In this mode, ImageGear does not scale images, only WPF does. For example, if the original image size is 1600x1200, the size of the ImageGear rendered image will also be 1600x1200, and WPF will scale it according to the display or printer resolution. See more details in Specifying Scale Settings (in the "WPF Scale Mode" section of "Scaling Modes").