Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
Windows XP icon and cursor support
Article ID: 307213 - View products that this article applies to.
This article was previously published under Q307213
This article discusses the following topics:
Icon colorsThe primary improvement to icons is that Microsoft Windows XP supports high-color and alpha-channel icons. Icons and cursors in Windows XP can be any color depth, to a maximum of 32 Bits-Per-Pixel (BPP). For an icon to contain an alpha channel, it must be 32 BPP, of which 24 bits are used for color red-green-blue (RGB) values, and 8 bits are used to store the alpha channel.
Icon selectionWhen an icon is loaded, the system does the following:
Consider the following bit depths: 2 BPP, 4 BPP, and 8 BPP. These are consecutive bit depths, and the delta between 2 BPP and 4 BPP is smaller than the delta between 4 BPP and 8 BPP. Therefore, the system would already select the lower color depth. Relaxing this punishment allows us to select a 32-BPP icon on a 24-BPP display device, instead of selecting the 8-BPP icon. This was necessary because the new user interface benefits from alpha-blended icons, but 24-BPP surfaces typically perform better than 32-BPP surfaces perform.
Cursor colorsA cursor is just an icon that has a hot spot that the system uses to interpret your intent when you point at something on the screen. Therefore, cursors are almost exactly the same as icons in their file format, except that some of the color information that is stored by an icon is used to store the hot spot in a cursor file. This similar file format limits cursors because when Windows XP implements the cursor loader, the color depth for a cursor is assumed to be 1 BPP.
Note The cursor is loaded properly at whatever color depth the cursor was authored. However, the system cannot distinguish between multiple candidates in the same cursor file or resource that differ only by their color depths. Icons, however, fully support multiple icon candidates with varying color depths.
Note Although it is possible for the system to examine the actual bitmaps that compose the cursor candidates to retrieve their actual color depths, Windows currently does not do this.
In the past, cursors were low-color, typically black and white, although some schemes included color versions. Windows XP supports 32-BPP cursors, which increases the possibilities for their use, although performance may suffer if your hardware is not adequately accelerated.
Note The system setting for a shadow under the mouse pointer is ignored if the cursor has an alpha channel (32 BPP).
For these reasons, Microsoft recommends that cursor sets be authored only at a single color depth. Microsoft also recommends the use of multiple sizes in the cursor set, especially if you might use the cursors on a high-DPI system.
Cursor sizesAlthough cursors can, in theory, be any size, the system imposes a standard size that is exposed by means of the SM_CXCURSOR and SM_CYCURSOR values. These metrics are read-only. On standard, low-DPI systems, these metrics are set to 32x32 pixels (32 bytes/row). When the system loads cursors by means of the standard LoadCursor function, the cursor is stretched to this dimension.
Most system cursors appear smaller than 32x32 and do not use some of the space around the cursor. The cursors in the extra-large schemes use more of the available 32x32 area. Windows XP does not include any system cursors that are larger than 32x32. (If larger cursors were included, they would be stretched down to 32x32 when the standard APIs load the cursors.)
For high-DPI systems, Windows XP has adjusted the SM_CXCURSOR and SM_CYCURSOR values to be 64x64 pixels. This size adjustment is to prevent the mouse pointer from virtually disappearing because it is too small to be effectively used. Although the other aspects of the system scale with DPI, the mouse pointer does not scale. Microsoft does not try to enforce a DPI-independent size for the mouse pointer.
The system also provides the SetSystemCursor API function that you can use to change the system cursor for specific categories. You can use this function to set a cursor of any size. However, you must call the function programmatically, and you can only use it to set a cursor for a specific category. You cannot use it to make all cursors on the system the same size.
For cursor sets that you want to use on high-DPI systems, Microsoft recommends that you author them with both 32x32 and 64x64 candidates. The system will select the appropriate candidate during loading, depending on the DPI of the system.
Cursor scaling problemsOccasionally, the system must scale a cursor. By default, the system performs a nearest-neighbor stretch. The results, although fast, are very pixilated; therefore, half-tone stretching has been enabled to produce a little better results. Unfortunately, half-tone stretching works best with source images that have many colors, and cursors typically have very few colors. Therefore, the stretching algorithms are limited in how pleasing the results can appear.
Most icons are authored at 32x32 pixels, and most systems do not stretch icons because they are low-DPI systems. However, High-DPI systems do stretch the default system cursors. Because half-tone stretching produces better visual results than pixilation, half-tone stretching is enabled.
Additionally, the stretching algorithms typically perform differently on the transparency mask and color images, resulting in a divergence. The mask is black and white; therefore, there can be no interpolated colors between adjacent pixels. The color image, however, frequently can support the interpolated colors. The frequent result is that the mask is shaped a little different from what you intended. This can lead to heavy borders, and in some cases, other incorrect visual effects along the borders. Cursors that contain an alpha channel instead of a transparency mask do not have this problem because the alpha channel is implicitly tied to the color information.
Finally, as the cursor is stretched, the hot spot (which is a single pixel) is more likely to move away from its intended position. As the cursor is scaled, the hot spot is adjusted, but with less refinement than the color information.