gimage.h 10.8 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#ifndef __GIMAGE_H__
#define __GIMAGE_H__

#include "boundary.h"
22
#include "drawable.h"
Elliot Lee's avatar
Elliot Lee committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include "channel.h"
#include "layer.h"
#include "paint_funcs.h"
#include "temp_buf.h"
#include "tile_manager.h"

/* the image types */
#define RGB_GIMAGE       0
#define RGBA_GIMAGE      1
#define GRAY_GIMAGE      2
#define GRAYA_GIMAGE     3
#define INDEXED_GIMAGE   4
#define INDEXEDA_GIMAGE  5

37 38
#define TYPE_HAS_ALPHA(t)  ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE)

Elliot Lee's avatar
Elliot Lee committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
#define GRAY_PIX         0
#define ALPHA_G_PIX      1
#define RED_PIX          0
#define GREEN_PIX        1
#define BLUE_PIX         2
#define ALPHA_PIX        3
#define INDEXED_PIX      0
#define ALPHA_I_PIX      1

#define RGB              0
#define GRAY             1
#define INDEXED          2

#define MAX_CHANNELS     4

/* the image fill types */
#define BACKGROUND_FILL  0
#define WHITE_FILL       1
#define TRANSPARENT_FILL 2
#define NO_FILL          3

#define COLORMAP_SIZE    768

#define HORIZONTAL_GUIDE 1
#define VERTICAL_GUIDE   2

typedef enum
{
  Red,
  Green,
  Blue,
  Gray,
  Indexed,
  Auxillary
} ChannelType;

typedef enum
{
  ExpandAsNecessary,
  ClipToImage,
  ClipToBottomLayer,
  FlattenImage
} MergeType;

/* structure declarations */

typedef struct _Guide  Guide;
typedef struct _GImage GImage;

struct _Guide
{
90
  int ref_count;
Elliot Lee's avatar
Elliot Lee committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  int position;
  int orientation;
};

struct _GImage
{
  char *filename;		      /*  original filename            */
  int has_filename;                   /*  has a valid filename         */

  int width, height;		      /*  width and height attributes  */
  int base_type;                      /*  base gimage type             */

  unsigned char * cmap;               /*  colormap--for indexed        */
  int num_cols;                       /*  number of cols--for indexed  */

  int dirty;                          /*  dirty flag -- # of ops       */
  int undo_on;                        /*  Is undo enabled?             */

  int instance_count;                 /*  number of instances          */
  int ref_count;                      /*  number of references         */

  TileManager *shadow;                /*  shadow buffer tiles          */

  int ID;                             /*  Unique gimage identifier     */

                                      /*  Projection attributes  */
  int flat;                           /*  Is the gimage flat?          */
  int construct_flag;                 /*  flag for construction        */
  int proj_type;                      /*  type of the projection image */
  int proj_bytes;                     /*  bpp in projection image      */
  int proj_level;                     /*  projection level             */
  TileManager *projection;            /*  The projection--layers &     */
                                      /*  channels                     */

  GList *guides;                      /*  guides                       */

                                      /*  Layer/Channel attributes  */
128 129 130
  GSList *layers;                     /*  the list of layers           */
  GSList *channels;                   /*  the list of masks            */
  GSList *layer_stack;                /*  the layers in MRU order      */
Elliot Lee's avatar
Elliot Lee committed
131

132 133 134
  Layer * active_layer;               /*  ID of active layer           */
  Channel * active_channel;	      /*  ID of active channel         */
  Layer * floating_sel;               /*  ID of fs layer               */
Elliot Lee's avatar
Elliot Lee committed
135 136 137 138 139 140 141 142 143
  Channel * selection_mask;           /*  selection mask channel       */

  int visible [MAX_CHANNELS];         /*  visible channels             */
  int active  [MAX_CHANNELS];         /*  active channels              */

  int by_color_select;                /*  TRUE if there's an active    */
                                      /*  "by color" selection dialog  */

                                      /*  Undo apparatus  */
144 145
  GSList *undo_stack;                 /*  stack for undo operations    */
  GSList *redo_stack;                 /*  stack for redo operations    */
Elliot Lee's avatar
Elliot Lee committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
  int undo_bytes;                     /*  bytes in undo stack          */
  int undo_levels;                    /*  levels in undo stack         */
  int pushing_undo_group;             /*  undo group status flag       */

                                      /*  Composite preview  */
  TempBuf *comp_preview;              /*  the composite preview        */
  int comp_preview_valid[3];          /*  preview valid-1/channel      */
};


/* function declarations */

GImage *        gimage_new                    (int, int, int);
void            gimage_set_filename           (GImage *, char *);
void            gimage_resize                 (GImage *, int, int, int, int);
void            gimage_scale                  (GImage *, int, int);
GImage *        gimage_get_named              (char *);
GImage *        gimage_get_ID                 (int);
TileManager *   gimage_shadow                 (GImage *, int, int, int);
void            gimage_free_shadow            (GImage *);
void            gimage_delete                 (GImage *);
167
void            gimage_apply_image            (GImage *, GimpDrawable *, PixelRegion *, int, int, int,
Elliot Lee's avatar
Elliot Lee committed
168
					       TileManager *, int, int);
169
void            gimage_replace_image          (GImage *, GimpDrawable *, PixelRegion *, int, int,
170
					       PixelRegion *, int, int);
171 172
void            gimage_get_foreground         (GImage *, GimpDrawable *, unsigned char *);
void            gimage_get_background         (GImage *, GimpDrawable *, unsigned char *);
Elliot Lee's avatar
Elliot Lee committed
173 174
void            gimage_get_color              (GImage *, int, unsigned char *,
					       unsigned char *);
175
void            gimage_transform_color        (GImage *, GimpDrawable *, unsigned char *,
Elliot Lee's avatar
Elliot Lee committed
176 177 178 179 180 181 182 183 184 185
					       unsigned char *, int);
Guide*          gimage_add_hguide             (GImage *);
Guide*          gimage_add_vguide             (GImage *);
void            gimage_add_guide              (GImage *, Guide *);
void            gimage_remove_guide           (GImage *, Guide *);
void            gimage_delete_guide           (GImage *, Guide *);


/*  layer/channel functions  */

186 187
int             gimage_get_layer_index        (GImage *, Layer *);
int             gimage_get_channel_index      (GImage *, Channel *);
Elliot Lee's avatar
Elliot Lee committed
188 189 190 191 192 193
Layer *         gimage_get_active_layer       (GImage *);
Channel *       gimage_get_active_channel     (GImage *);
Channel *       gimage_get_mask               (GImage *);
int             gimage_get_component_active   (GImage *, ChannelType);
int             gimage_get_component_visible  (GImage *, ChannelType);
int             gimage_layer_boundary         (GImage *, BoundSeg **, int *);
194 195
Layer *         gimage_set_active_layer       (GImage *, Layer *);
Channel *       gimage_set_active_channel     (GImage *, Channel *);
Elliot Lee's avatar
Elliot Lee committed
196 197 198 199 200
Channel *       gimage_unset_active_channel   (GImage *);
void            gimage_set_component_active   (GImage *, ChannelType, int);
void            gimage_set_component_visible  (GImage *, ChannelType, int);
Layer *         gimage_pick_correlate_layer   (GImage *, int, int);
void            gimage_set_layer_mask_apply   (GImage *, int);
201
void            gimage_set_layer_mask_edit    (GImage *, Layer *, int);
Elliot Lee's avatar
Elliot Lee committed
202
void            gimage_set_layer_mask_show    (GImage *, int);
203 204
Layer *         gimage_raise_layer            (GImage *, Layer *);
Layer *         gimage_lower_layer            (GImage *, Layer *);
Elliot Lee's avatar
Elliot Lee committed
205 206
Layer *         gimage_merge_visible_layers   (GImage *, MergeType);
Layer *         gimage_flatten                (GImage *);
207
Layer *         gimage_merge_layers           (GImage *, GSList *, MergeType);
Elliot Lee's avatar
Elliot Lee committed
208
Layer *         gimage_add_layer              (GImage *, Layer *, int);
209 210 211 212 213
Layer *         gimage_remove_layer           (GImage *, Layer *);
LayerMask *     gimage_add_layer_mask         (GImage *, Layer *, LayerMask *);
Channel *       gimage_remove_layer_mask      (GImage *, Layer *, int);
Channel *       gimage_raise_channel          (GImage *, Channel *);
Channel *       gimage_lower_channel          (GImage *, Channel *);
Elliot Lee's avatar
Elliot Lee committed
214
Channel *       gimage_add_channel            (GImage *, Channel *, int);
215
Channel *       gimage_remove_channel         (GImage *, Channel *);
Elliot Lee's avatar
Elliot Lee committed
216 217 218 219 220 221 222 223 224 225 226
void            gimage_construct              (GImage *, int, int, int, int);
void            gimage_invalidate             (GImage *, int, int, int, int, int, int, int, int);
void            gimage_validate               (TileManager *, Tile *, int);
void            gimage_inflate                (GImage *);
void            gimage_deflate                (GImage *);


/*  Access functions  */

int             gimage_is_flat                (GImage *);
int             gimage_is_empty               (GImage *);
227
GimpDrawable *  gimage_active_drawable        (GImage *);
Elliot Lee's avatar
Elliot Lee committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
int             gimage_base_type              (GImage *);
int             gimage_base_type_with_alpha   (GImage *);
char *          gimage_filename               (GImage *);
int             gimage_enable_undo            (GImage *);
int             gimage_disable_undo           (GImage *);
int             gimage_dirty                  (GImage *);
int             gimage_clean                  (GImage *);
void            gimage_clean_all              (GImage *);
Layer *         gimage_floating_sel           (GImage *);
unsigned char * gimage_cmap                   (GImage *);


/*  projection access functions  */

TileManager *   gimage_projection             (GImage *);
int             gimage_projection_type        (GImage *);
int             gimage_projection_bytes       (GImage *);
int             gimage_projection_opacity     (GImage *);
void            gimage_projection_realloc     (GImage *);


/*  composite access functions  */

TileManager *   gimage_composite              (GImage *);
int             gimage_composite_type         (GImage *);
int             gimage_composite_bytes        (GImage *);
TempBuf *       gimage_composite_preview      (GImage *, ChannelType, int, int);
int             gimage_preview_valid          (GImage *, ChannelType);
void            gimage_invalidate_preview     (GImage *);

void            gimage_invalidate_previews    (void);

260 261 262
/* from drawable.c */
GImage *        drawable_gimage               (GimpDrawable*);

Elliot Lee's avatar
Elliot Lee committed
263
#endif /* __GIMAGE_H__ */