ico.h 3.07 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
 *
 * GIMP Plug-in for Windows Icon files.
 * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __MAIN_H__
#define __MAIN_H__


#ifdef ICO_DBG
#define D(x) \
{ \
  printf("ICO plugin: "); \
  printf x; \
}
#else
#define D(x)
#endif

36
#define ICO_PNG_MAGIC       0x474e5089
Sven Neumann's avatar
Sven Neumann committed
37 38
#define ICO_ALPHA_THRESHOLD 127
#define ICO_MAXBUF          4096
39 40


Sven Neumann's avatar
Sven Neumann committed
41
typedef struct _IcoFileHeader
42
{
Sven Neumann's avatar
Sven Neumann committed
43 44 45 46
  guint16   reserved;
  guint16   resource_type;
  guint16   icon_count;
} IcoFileHeader;
47

Sven Neumann's avatar
Sven Neumann committed
48 49 50 51 52 53 54 55 56 57 58 59 60
typedef struct _IcoFileEntry
{
  guint8        width;      /* Width of icon in pixels */
  guint8        height;    /* Height of icon in pixels */
  guint8        num_colors; /* Number of colors of paletted image */
  guint8        reserved;   /* Must be 0 */
  guint16       planes;     /* Must be 1 */
  guint16       bpp;        /* 1, 4, 8, 24 or 32 bits per pixel */
  guint32       size;       /* Size of icon (including data header) */
  guint32       offset;     /* Absolute offset of data in a file */
 } IcoFileEntry;

typedef struct _IcoFileDataHeader
61
{
Sven Neumann's avatar
Sven Neumann committed
62 63 64 65
  guint32       header_size; /* 40 bytes */
  guint32       width;       /* Width of image in pixels */
  guint32       height;      /* Height of image in pixels */
  guint16       planes;      /* Must be 1 */
66
  guint16       bpp;
Sven Neumann's avatar
Sven Neumann committed
67 68
  guint32       compression; /* Not used for icons */
  guint32       image_size;  /* Size of image (without this header) */
69 70 71 72
  guint32       x_res;
  guint32       y_res;
  guint32       used_clrs;
  guint32       important_clrs;
Sven Neumann's avatar
Sven Neumann committed
73
} IcoFileDataHeader;
74 75


Sven Neumann's avatar
Sven Neumann committed
76
typedef struct _IcoLoadInfo
77
{
Sven Neumann's avatar
Sven Neumann committed
78 79 80 81 82 83 84 85 86 87 88
    guint    width;
    guint    height;
    gint     bpp;
    gint     offset;
    gint     size;
} IcoLoadInfo;

typedef struct _IcoSaveInfo
{
    gint        *depths;
    gint        *default_depths;
89
    gboolean    *compress;
Sven Neumann's avatar
Sven Neumann committed
90 91 92
    gint        *layers;
    gint         num_icons;
} IcoSaveInfo;
93 94 95 96


/* Miscellaneous helper functions below: */

Sven Neumann's avatar
Sven Neumann committed
97 98 99
gint     ico_rowstride (gint width,
                        gint bpp);

100 101 102
/* Allocates a 32-bit padded bitmap for various color depths.
   Returns the allocated array directly, and the length of the
   array in the len pointer */
103
guint8 * ico_alloc_map  (gint     width,
Sven Neumann's avatar
Sven Neumann committed
104 105 106
                         gint     height,
                         gint     bpp,
                         gint    *len);
107

108
#endif /* __MAIN_H__ */