|
Packit |
78deda |
#include "pm_c_util.h"
|
|
Packit |
78deda |
|
|
Packit |
78deda |
#define ICONDIR_TYPE_ICO (1)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
/* windows icon structures */
|
|
Packit |
78deda |
struct IconDirEntry {
|
|
Packit |
78deda |
uint16_t width; /* image width in pixels 0 == 256 */
|
|
Packit |
78deda |
uint16_t height; /* image height in pixels 0 == 256 */
|
|
Packit |
78deda |
uint8_t color_count; /* 0 if bits_per_pixel >= 8 */
|
|
Packit |
78deda |
uint8_t zero; /* 0 */
|
|
Packit |
78deda |
uint16_t color_planes; /* 1 */
|
|
Packit |
78deda |
uint16_t bits_per_pixel; /* allowed values: 1, 4, 8, 16 or 32 (1) */
|
|
Packit |
78deda |
uint32_t size; /* size of image */
|
|
Packit |
78deda |
uint32_t offset; /* file offset of image */
|
|
Packit |
78deda |
|
|
Packit |
78deda |
uint16_t index; /* extra field (not in file) */
|
|
Packit |
78deda |
};
|
|
Packit |
78deda |
|
|
Packit |
78deda |
/* (1) This is from
|
|
Packit |
78deda |
* http://blogs.msdn.com/b/oldnewthing/archive/2010/10/19/10077610.aspx.
|
|
Packit |
78deda |
*
|
|
Packit |
78deda |
* However, the bpp value in the icon directory is used as a hint for
|
|
Packit |
78deda |
* image selection only. It seems to be legal to set this value to
|
|
Packit |
78deda |
* zero, and e.g. in SHELL32.DLL of Win98SE, there are many 8bpp
|
|
Packit |
78deda |
* images described as 24 bit images in the icon directory.
|
|
Packit |
78deda |
*
|
|
Packit |
78deda |
* The bpp value of image 1 in icon 150 in SHELL32.DLL of WinXP is 24
|
|
Packit |
78deda |
* (in header and BMP). This may be a bug, as the 32 x 32 x 8 image
|
|
Packit |
78deda |
* is missing, but it shows the Windows icon rendering engine is able
|
|
Packit |
78deda |
* to cope with 24 bit images).
|
|
Packit |
78deda |
*
|
|
Packit |
78deda |
* 16bpp icons are at least rare in the wild.
|
|
Packit |
78deda |
*/
|
|
Packit |
78deda |
struct IconDir {
|
|
Packit |
78deda |
uint16_t zero; /* 0 */
|
|
Packit |
78deda |
uint16_t type; /* 1 */
|
|
Packit |
78deda |
uint16_t count; /* number of images in icon */
|
|
Packit |
78deda |
|
|
Packit |
78deda |
unsigned int entriesAllocCt; /* # of allocated slots in 'entries'*/
|
|
Packit |
78deda |
struct IconDirEntry * entries; /* one entry for each image */
|
|
Packit |
78deda |
};
|
|
Packit |
78deda |
|
|
Packit |
78deda |
/* BMP image structures */
|
|
Packit |
78deda |
|
|
Packit |
78deda |
struct BitmapInfoHeader {
|
|
Packit |
78deda |
uint32_t header_size; /* >= 40 */
|
|
Packit |
78deda |
int32_t bm_width;
|
|
Packit |
78deda |
int32_t bm_height;
|
|
Packit |
78deda |
uint16_t color_planes;
|
|
Packit |
78deda |
uint16_t bits_per_pixel;
|
|
Packit |
78deda |
uint32_t compression_method;
|
|
Packit |
78deda |
uint32_t image_size;
|
|
Packit |
78deda |
int32_t horizontal_resolution; /* pixels per meter (!) */
|
|
Packit |
78deda |
int32_t vertical_resolution; /* pixels per meter (!) */
|
|
Packit |
78deda |
uint32_t colors_in_palette;
|
|
Packit |
78deda |
uint32_t important_colors;
|
|
Packit |
78deda |
|
|
Packit |
78deda |
bool top_down; /* extra field (not in file) */
|
|
Packit |
78deda |
|
|
Packit |
78deda |
};
|
|
Packit |
78deda |
|
|
Packit |
78deda |
typedef enum {
|
|
Packit |
78deda |
BI_RGB = 0,
|
|
Packit |
78deda |
BI_BITFIELDS = 3
|
|
Packit |
78deda |
|
|
Packit |
78deda |
} BiCompression;
|
|
Packit |
78deda |
|
|
Packit |
78deda |
/* PNG image structures */
|
|
Packit |
78deda |
#define PNG_HEADER { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1A /* ^Z */, '\n' }
|
|
Packit |
78deda |
|
|
Packit |
78deda |
struct PngIhdr {
|
|
Packit |
78deda |
uint32_t length; /* 13 */
|
|
Packit |
78deda |
uint32_t signature; /* "IHDR" */
|
|
Packit |
78deda |
uint32_t width; /* image width in pixels */
|
|
Packit |
78deda |
uint32_t height; /* image height in pixels */
|
|
Packit |
78deda |
uint8_t bit_depth; /* depth per channel */
|
|
Packit |
78deda |
uint8_t color_type; /* recognized values: 0, 2, 3, 4 and 6 */
|
|
Packit |
78deda |
uint8_t compression;
|
|
Packit |
78deda |
uint8_t filter;
|
|
Packit |
78deda |
uint8_t interlace;
|
|
Packit |
78deda |
uint32_t crc;
|
|
Packit |
78deda |
};
|