1 // Copyright 2008-present Contributors to the OpenImageIO project.
2 // SPDX-License-Identifier: BSD-3-Clause
3 // https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
4 
5 #pragma once
6 
7 #include <OpenImageIO/oiioversion.h>
8 
9 
10 OIIO_PLUGIN_NAMESPACE_BEGIN
11 
12 namespace ICO_pvt {
13 
14 // IneQuation was here
15 
16 // Win32 (pre-Vista) ICO format as described in these documents:
17 // http://msdn.microsoft.com/en-us/library/ms997538.aspx
18 // http://en.wikipedia.org/wiki/ICO_(icon_image_file_format)
19 // http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx
20 // ...plus some of my own magic.
21 
22 /// Win32 DIB (Device-Independent Bitmap) header.
23 /// According to MSDN, only size, width, height, planes, bpp and len are
24 /// valid for ICOs.
25 struct ico_bitmapinfo {
26     int32_t size;  ///< structure size in bytes (how about a sizeof?)
27     int32_t width;
28     int32_t height;
29     int16_t planes;       ///< # of colour planes
30     int16_t bpp;          ///< bits per pixel
31     int32_t compression;  ///< unused: compression type
32     int32_t len;    ///< image size in bytes; may be 0 for uncompressed bitmaps
33     int32_t x_res;  ///< unused: resolution of target device in pixels per metre
34     int32_t y_res;  ///< unused: resolution of target device in pixels per metre
35     int32_t clrs_used;  ///< # of colours used (if using a palette)
36     int32_t
37         clrs_required;  ///< # of colours required to display the bitmap; 0 = all of them
38 };
39 
40 /// Icon palette entry. Attached at each
41 struct ico_palette_entry {
42     int8_t b, g, r;
43     int8_t reserved;  // unused
44 };
45 
46 
47 struct ico_subimage {
48     uint8_t width;       ///< 0 means 256 pixels
49     uint8_t height;      ///< 0 means 256 pixels
50     uint8_t numColours;  ///< 0 means >= 256
51     uint8_t reserved;    ///< should always be 0
52     uint16_t planes;     ///< # of colour planes
53     uint16_t bpp;        ///< bits per pixel
54     uint32_t len;        ///< size (in bytes) of bitmap data
55     uint32_t ofs;        ///< offset to bitmap data
56 };
57 
58 
59 struct ico_header {
60     int16_t reserved;  ///< should always be 0
61     int16_t type;      ///< 1 is icon, 2 is cursor
62     int16_t count;     ///< number of subimages in the file
63 };
64 
65 
66 }  // namespace ICO_pvt
67 
68 
69 OIIO_PLUGIN_NAMESPACE_END
70