Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
An alternative to scaling is using multiple images, each authored for a different DPI. This technique yields the best results.
The .ico format is already capable of storing multiple image sizes in a single file. When you load the icon or cursor, the application asks for the size that the GetSystemMetricsfunction suggests; the system then picks the closest image.
The following code example shows how to select from multiple images that are not in .ico format. To be completely DPI aware, an application should still scale the loaded bitmap based on the actual DPI of the device, because it should make no assumption about what DPI resolutions are available.
Copy Code | |
---|---|
if (GetDeviceCaps(hdc, LOGPIXELSX) < 130) bitmap = LoadBitmap(hInstance, (char*) IDB_BITMAP1); else bitmap = LoadBitmap(hInstance, (char*) IDB_BITMAP2); |
When the loaded bitmap is already authored for the correct DPI, scaling it will have no adverse effect on performance or image quality.