1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis 3 * 4 * GIMP Plug-in for Windows Icon files. 5 * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __ICO_H__ 22 #define __ICO_H__ 23 24 25 #ifdef ICO_DBG 26 #define D(x) \ 27 { \ 28 printf("ICO plugin: "); \ 29 printf x; \ 30 } 31 #else 32 #define D(x) 33 #endif 34 35 #define PLUG_IN_BINARY "file-ico" 36 #define PLUG_IN_ROLE "gimp-file-ico" 37 38 #define ICO_PNG_MAGIC 0x474e5089 39 #define ICO_ALPHA_THRESHOLD 127 40 #define ICO_MAXBUF 4096 41 42 43 typedef struct _IcoFileHeader 44 { 45 guint16 reserved; 46 guint16 resource_type; 47 guint16 icon_count; 48 } IcoFileHeader; 49 50 typedef struct _IcoFileEntry 51 { 52 guint8 width; /* Width of icon in pixels */ 53 guint8 height; /* Height of icon in pixels */ 54 guint8 num_colors; /* Number of colors of paletted image */ 55 guint8 reserved; /* Must be 0 */ 56 guint16 planes; /* Must be 1 */ 57 guint16 bpp; /* 1, 4, 8, 24 or 32 bits per pixel */ 58 guint32 size; /* Size of icon (including data header) */ 59 guint32 offset; /* Absolute offset of data in a file */ 60 } IcoFileEntry; 61 62 typedef struct _IcoFileDataHeader 63 { 64 guint32 header_size; /* 40 bytes */ 65 guint32 width; /* Width of image in pixels */ 66 guint32 height; /* Height of image in pixels */ 67 guint16 planes; /* Must be 1 */ 68 guint16 bpp; 69 guint32 compression; /* Not used for icons */ 70 guint32 image_size; /* Size of image (without this header) */ 71 guint32 x_res; 72 guint32 y_res; 73 guint32 used_clrs; 74 guint32 important_clrs; 75 } IcoFileDataHeader; 76 77 78 typedef struct _IcoLoadInfo 79 { 80 guint width; 81 guint height; 82 gint bpp; 83 gint offset; 84 gint size; 85 } IcoLoadInfo; 86 87 typedef struct _IcoSaveInfo 88 { 89 gint *depths; 90 gint *default_depths; 91 gboolean *compress; 92 gint *layers; 93 gint num_icons; 94 } IcoSaveInfo; 95 96 97 /* Miscellaneous helper functions below: */ 98 99 gint ico_rowstride (gint width, 100 gint bpp); 101 102 /* Allocates a 32-bit padded bitmap for various color depths. 103 Returns the allocated array directly, and the length of the 104 array in the len pointer */ 105 guint8 * ico_alloc_map (gint width, 106 gint height, 107 gint bpp, 108 gint *len); 109 110 #endif /* __ICO_H__ */ 111