A Windows cursor file, .cur, is laid out exactly as an ICO file, with two
differences: idType is 2, and in each directory entry the hotspot takes the
place of the planes and bit count. Everything else about its
images and their
masks is the same. Animated cursors are a different
format, ANI.
00000000 00 00 02 00 01 00 20 20 00 00 05 00 09 00 30 01
00000010 00 00 16 00 00 00
The directory entry
A cursor’s entry is an ICONDIRENTRY
with two fields renamed. Offsets are from the start of the entry.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 1 | u8 | bWidth | The width in pixels. 0 means 256. |
| 1 | 1 | u8 | bHeight | The height in pixels. 0 means 256. |
| 2 | 1 | u8 | bColorCount | The number of colours. No published rule covers cursors, and many real cursor files leave it 0 even at 1 and 4 bits per pixel. |
| 3 | 1 | u8 | bReserved | Reserved. Must be 0. |
| 4 | 2 | u16 | wXHotspot | The x position of the hotspot, from the left. |
| 6 | 2 | u16 | wYHotspot | The y position of the hotspot, from the top. |
| 8 | 4 | u32 | dwBytesInRes | The size of the image in bytes. |
| 12 | 4 | u32 | dwImageOffset | The offset of the image from the start of the file. |
The depth is not in a cursor’s directory, so it comes from the image’s own header.
The hotspot
The hotspot is the one pixel of the cursor that counts as its position, such as the tip of an arrow. It is measured in pixels from the top-left corner of the image, so (0, 0) is the top-left pixel, and each image in the file has its own. It should lie inside the image.
Cursors inside programs
In a program, each cursor image is an RT_CURSOR resource, and an
RT_GROUP_CURSOR resource lists them. The group starts with a
NEWHEADER: a reserved 16-bit word that must be 0, ResType, which is
2 (RES_CURSOR) for a cursor and 1 (RES_ICON) for an icon, and
ResCount, the number of images. Then come the RESDIR structures, and
a cursor’s starts with a CURSORDIR where an icon’s has width, height and
colours:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | u16 | Width | The width in pixels. 0 means 256. |
| 2 | 2 | u16 | Height | The height in pixels. 0 means 256. |
| 4 | 2 | u16 | Planes | The number of colour planes. |
| 6 | 2 | u16 | BitCount | Bits per pixel. |
| 8 | 4 | u32 | BytesInRes | The size of the resource. |
| 12 | 2 | u16 | IconCursorId | The identifier of the RT_CURSOR resource. |
The hotspot moves out of the directory and into the image: the resource starts with a
LOCALHEADER, two 16-bit numbers, then the image’s bytes.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | u16 | xHotSpot | The x position of the hotspot, in pixels. |
| 2 | 2 | u16 | yHotSpot | The y position of the hotspot, in pixels. |