gimpimage.h 23.1 KB
Newer Older
1
/* The GIMP -- an image manipulation program
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * 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.
 */
18

19 20
#ifndef __GIMP_IMAGE_H__
#define __GIMP_IMAGE_H__
21 22


23
#include "gimpviewable.h"
24

25

Michael Natterer's avatar
Michael Natterer committed
26 27
#define COLORMAP_SIZE 768

28 29 30 31 32 33 34
#define GIMP_IMAGE_TYPE_IS_RGB(t)          ((t) == GIMP_RGB_IMAGE ||         \
				            (t) == GIMP_RGBA_IMAGE)
#define GIMP_IMAGE_TYPE_IS_GRAY(t)         ((t) == GIMP_GRAY_IMAGE ||        \
				            (t) == GIMP_GRAYA_IMAGE)
#define GIMP_IMAGE_TYPE_IS_INDEXED(t)      ((t) == GIMP_INDEXED_IMAGE ||     \
				            (t) == GIMP_INDEXEDA_IMAGE)

35 36 37
#define GIMP_IMAGE_TYPE_HAS_ALPHA(t)       ((t) == GIMP_RGBA_IMAGE  ||       \
				            (t) == GIMP_GRAYA_IMAGE ||       \
				            (t) == GIMP_INDEXEDA_IMAGE)
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#define GIMP_IMAGE_TYPE_WITH_ALPHA(t)     (((t) == GIMP_RGB_IMAGE ||         \
                                            (t) == GIMP_RGBA_IMAGE) ?        \
                                           GIMP_RGBA_IMAGE :                 \
                                           ((t) == GIMP_GRAY_IMAGE ||        \
                                            (t) == GIMP_GRAYA_IMAGE) ?       \
                                           GIMP_GRAYA_IMAGE :                \
                                           ((t) == GIMP_INDEXED_IMAGE ||     \
                                            (t) == GIMP_INDEXEDA_IMAGE) ?    \
                                           GIMP_INDEXEDA_IMAGE : -1)
#define GIMP_IMAGE_TYPE_BYTES(t)           ((t) == GIMP_RGBA_IMAGE     ? 4 : \
                                            (t) == GIMP_RGB_IMAGE      ? 3 : \
                                            (t) == GIMP_GRAYA_IMAGE    ? 2 : \
                                            (t) == GIMP_GRAY_IMAGE     ? 1 : \
                                            (t) == GIMP_INDEXEDA_IMAGE ? 2 : \
                                            (t) == GIMP_INDEXED_IMAGE  ? 1 : -1)
54 55 56 57 58 59 60 61 62
#define GIMP_IMAGE_TYPE_BASE_TYPE(t)      (((t) == GIMP_RGB_IMAGE ||         \
                                            (t) == GIMP_RGBA_IMAGE) ?        \
                                           GIMP_RGB :                        \
                                           ((t) == GIMP_GRAY_IMAGE ||        \
                                            (t) == GIMP_GRAYA_IMAGE) ?       \
                                           GIMP_GRAY :                       \
                                           ((t) == GIMP_INDEXED_IMAGE ||     \
                                            (t) == GIMP_INDEXEDA_IMAGE) ?    \
                                           GIMP_INDEXED : -1)
63 64 65 66 67 68 69

#define GIMP_IMAGE_TYPE_FROM_BASE_TYPE(b)  ((b) == GIMP_RGB ?                \
                                            GIMP_RGB_IMAGE :                 \
                                            (b) == GIMP_GRAY ?               \
                                            GIMP_GRAY_IMAGE :                \
                                            (b) == GIMP_INDEXED ?            \
                                            GIMP_INDEXED_IMAGE : -1)
70

71

Michael Natterer's avatar
Michael Natterer committed
72 73
struct _GimpGuide
{
74
  gint                     ref_count;
Michael Natterer's avatar
Michael Natterer committed
75 76 77 78 79 80
  gint                     position;
  InternalOrientationType  orientation;
  guint32                  guide_ID;
};


81
#define GIMP_TYPE_IMAGE            (gimp_image_get_type ())
82 83 84
#define GIMP_IMAGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE, GimpImage))
#define GIMP_IMAGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE, GimpImageClass))
#define GIMP_IS_IMAGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE))
85
#define GIMP_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE))
86 87
#define GIMP_IMAGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE, GimpImageClass))

88 89 90 91 92

typedef struct _GimpImageClass GimpImageClass;

struct _GimpImage
{
93
  GimpViewable       parent_instance;
94

95
  Gimp              *gimp;                  /*  the GIMP the image belongs to*/
96

97 98
  gint               ID;                    /*  provides a unique ID         */

99 100
  PlugInProcDef     *save_proc;             /*  last PDB save proc used      */

101
  gint               width, height;         /*  width and height attributes  */
102 103 104 105 106 107 108 109
  gdouble            xresolution;           /*  image x-res, in dpi          */
  gdouble            yresolution;           /*  image y-res, in dpi          */
  GimpUnit           unit;                  /*  image unit                   */
  GimpImageBaseType  base_type;             /*  base gimp_image type         */

  guchar            *cmap;                  /*  colormap--for indexed        */
  gint               num_cols;              /*  number of cols--for indexed  */

110 111
  gint               dirty;                 /*  dirty flag -- # of ops       */
  gboolean           undo_on;               /*  Is undo enabled?             */
112

113 114
  gint               instance_count;        /*  number of instances          */
  gint               disp_count;            /*  number of displays           */
115

116
  GimpTattoo         tattoo_state;          /*  the next unique tattoo to use*/
117 118 119

  TileManager       *shadow;                /*  shadow buffer tiles          */

120
  /*  Projection attributes  */
121
  gboolean           construct_flag;        /*  flag for construction        */
122 123 124 125 126 127 128 129
  GimpImageType      proj_type;             /*  type of the projection image */
  gint               proj_bytes;            /*  bpp in projection image      */
  gint               proj_level;            /*  projection level             */
  TileManager       *projection;            /*  The projection--layers &     */
                                            /*  channels                     */

  GList             *guides;                /*  guides                       */

130
  /*  Layer/Channel attributes  */
131 132
  GimpContainer     *layers;                /*  the list of layers           */
  GimpContainer     *channels;              /*  the list of masks            */
133 134
  GSList            *layer_stack;           /*  the layers in MRU order      */

135 136 137 138
  GimpLayer         *active_layer;          /*  the active layer             */
  GimpChannel       *active_channel;        /*  the active channel           */
  GimpLayer         *floating_sel;          /*  the FS layer                 */
  GimpChannel       *selection_mask;        /*  the selection mask channel   */
139

140
  GimpParasiteList  *parasites;             /*  Plug-in parasite data        */
141 142 143

  PathList          *paths;                 /*  Paths data for this image    */

144 145
  gboolean           visible[MAX_CHANNELS]; /*  visible channels             */
  gboolean           active[MAX_CHANNELS];  /*  active channels              */
146

147 148
  gboolean           qmask_state;           /*  TRUE if qmask is on          */
  gboolean           qmask_inverted;        /*  TRUE if qmask is inverted    */
149
  GimpRGB            qmask_color;           /*  rgba triplet of the color    */
150

151
  /*  Old undo apparatus  */
152 153
  GSList            *undo_stack;            /*  stack for undo operations    */
  GSList            *redo_stack;            /*  stack for redo operations    */
154 155 156
  gint               undo_bytes;            /*  bytes in undo stack          */
  gint               undo_levels;           /*  levels in undo stack         */
  gint               group_count;           /*  nested undo groups           */
157 158
  UndoType           pushing_undo_group;    /*  undo group status flag       */

159 160 161 162
  /*  New undo apparatus  */
  GimpUndoStack     *new_undo_stack;        /*  stack for undo operations    */
  GimpUndoStack     *new_redo_stack;        /*  stack for redo operations    */

163
  /*  Composite preview  */
164
  TempBuf           *comp_preview;          /*  the composite preview        */
165
  gboolean           comp_preview_valid;    /*  preview valid-1/channel      */
166 167 168
};

struct _GimpImageClass
169
{
170
  GimpViewableClass  parent_class;
171

172 173 174 175 176 177
  void (* mode_changed)                 (GimpImage            *gimage);
  void (* alpha_changed)                (GimpImage            *gimage);
  void (* floating_selection_changed)   (GimpImage            *gimage);
  void (* active_layer_changed)         (GimpImage            *gimage);
  void (* active_channel_changed)       (GimpImage            *gimage);
  void (* component_visibility_changed) (GimpImage            *gimage,
178
					 GimpChannelType       channel);
179
  void (* component_active_changed)     (GimpImage            *gimage,
180
					 GimpChannelType       channel);
181
  void (* mask_changed)                 (GimpImage            *gimage);
182 183
  void (* resolution_changed)           (GimpImage            *gimage);
  void (* unit_changed)                 (GimpImage            *gimage);
Michael Natterer's avatar
Michael Natterer committed
184
  void (* qmask_changed)                (GimpImage            *gimage);
185 186 187 188 189 190 191 192 193 194
  void (* selection_control)            (GimpImage            *gimage,
                                         GimpSelectionControl  control);

  void (* clean)                        (GimpImage            *gimage);
  void (* dirty)                        (GimpImage            *gimage);
  void (* update)                       (GimpImage            *gimage,
					 gint                  x,
					 gint                  y,
					 gint                  width,
					 gint                  height);
195 196
  void (* update_guide)                 (GimpImage            *gimage,
                                         GimpGuide            *guide);
197 198 199 200 201 202 203
  void (* colormap_changed)             (GimpImage            *gimage,
					 gint                  color_index);
  void (* undo_event)                   (GimpImage            *gimage,
					 gint                  event);

  void (* undo)                         (GimpImage            *gimage);
  void (* redo)                         (GimpImage            *gimage);
204 205
};

206

207
GType           gimp_image_get_type              (void) G_GNUC_CONST;
208

209 210 211 212
GimpImage     * gimp_image_new                   (Gimp               *gimp,
                                                  gint                width,
                                                  gint                height,
                                                  GimpImageBaseType   base_type);
213
 
214 215 216 217 218
GimpImageBaseType  gimp_image_base_type            (const GimpImage  *gimage);
GimpImageType	   gimp_image_base_type_with_alpha (const GimpImage  *gimage);
CombinationMode    gimp_image_get_combination_mode (GimpImageType     dest_type,
                                                    gint              src_bytes);

219
gint            gimp_image_get_ID                (const GimpImage    *gimage);
220 221 222 223 224 225 226 227 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
GimpImage     * gimp_image_get_by_ID             (Gimp               *gimp,
                                                  gint                id);

void            gimp_image_set_filename          (GimpImage          *gimage,
                                                  const gchar        *filename);
const gchar   * gimp_image_get_filename          (const GimpImage    *gimage);

void            gimp_image_set_save_proc         (GimpImage          *gimage,
                                                  PlugInProcDef      *proc);
PlugInProcDef * gimp_image_get_save_proc         (const GimpImage    *gimage);

void            gimp_image_set_resolution        (GimpImage          *gimage,
                                                  gdouble             xres,
                                                  gdouble             yres);
void            gimp_image_get_resolution        (const GimpImage    *gimage,
                                                  gdouble            *xres,
                                                  gdouble            *yres);
void            gimp_image_resolution_changed    (GimpImage          *gimage);

void            gimp_image_set_unit              (GimpImage          *gimage,
                                                  GimpUnit            unit);
GimpUnit        gimp_image_get_unit              (const GimpImage    *gimage);
void            gimp_image_unit_changed          (GimpImage          *gimage);

gint		gimp_image_get_width             (const GimpImage    *gimage);
gint		gimp_image_get_height            (const GimpImage    *gimage);

gboolean        gimp_image_is_empty              (const GimpImage    *gimage);

GimpLayer     * gimp_image_floating_sel          (const GimpImage    *gimage);
void       gimp_image_floating_selection_changed (GimpImage          *gimage);

guchar        * gimp_image_get_colormap          (const GimpImage    *gimage);
void		gimp_image_colormap_changed      (GimpImage          *gimage,
                                                  gint                col);

GimpChannel   * gimp_image_get_mask              (const GimpImage    *gimage);
void            gimp_image_mask_changed          (GimpImage          *gimage);

void            gimp_image_set_component_active  (GimpImage          *gimage,
260
						  GimpChannelType     type,
261 262
						  gboolean            active);
gboolean        gimp_image_get_component_active  (const GimpImage    *gimage,
263 264 265
						  GimpChannelType     type);
void            gimp_image_get_active_components (const GimpImage    *gimage,
                                                  const GimpDrawable *drawable,
266 267 268
                                                  gint               *active);

void            gimp_image_set_component_visible (GimpImage          *gimage,
269
						  GimpChannelType     type,
270 271
						  gboolean            visible);
gboolean        gimp_image_get_component_visible (const GimpImage    *gimage,
272
						  GimpChannelType     type);
273 274 275 276 277 278 279 280 281 282 283 284

void            gimp_image_mode_changed          (GimpImage          *gimage);
void            gimp_image_alpha_changed         (GimpImage          *gimage);
void            gimp_image_update                (GimpImage          *gimage,
                                                  gint                x,
                                                  gint                y,
                                                  gint                width,
                                                  gint                height);
void            gimp_image_update_guide          (GimpImage          *gimage,
                                                  GimpGuide          *guide);
void            gimp_image_selection_control     (GimpImage          *gimage,
                                                  GimpSelectionControl  control);
285
void            gimp_image_qmask_changed         (GimpImage          *gimage);
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336


/*  undo  */

gboolean        gimp_image_undo_is_enabled       (const GimpImage    *gimage);
gboolean        gimp_image_undo_enable           (GimpImage          *gimage);
gboolean        gimp_image_undo_disable          (GimpImage          *gimage);
gboolean        gimp_image_undo_freeze           (GimpImage          *gimage);
gboolean        gimp_image_undo_thaw             (GimpImage          *gimage);
void		gimp_image_undo_event            (GimpImage          *gimage,
                                                  gint                event);
gint            gimp_image_dirty                 (GimpImage          *gimage);
gint            gimp_image_clean                 (GimpImage          *gimage);
void            gimp_image_clean_all             (GimpImage          *gimage);


/*  color transforms / utilities  */

void            gimp_image_get_foreground        (const GimpImage    *gimage,
                                                  const GimpDrawable *drawable,
                                                  guchar             *fg);
void            gimp_image_get_background        (const GimpImage    *gimage,
                                                  const GimpDrawable *drawable,
                                                  guchar             *bg);
void            gimp_image_get_color             (const GimpImage    *gimage,
                                                  GimpImageType       d_type,
                                                  guchar             *rgb,
                                                  guchar             *src);
void            gimp_image_transform_color       (const GimpImage    *gimage,
                                                  const GimpDrawable *drawable,
                                                  guchar             *src,
                                                  guchar             *dest,
                                                  GimpImageBaseType   type);


/*  shadow tiles  */

TileManager   * gimp_image_shadow                (GimpImage          *gimage,
                                                  gint                width,
                                                  gint                height,
                                                  gint                bpp);
void            gimp_image_free_shadow           (GimpImage          *gimage);


/*  combine functions  */

void            gimp_image_apply_image           (GimpImage          *gimage,
                                                  GimpDrawable       *drawable,
                                                  PixelRegion        *src2PR,
                                                  gboolean            undo,
                                                  gint                opacity,
337
                                                  GimpLayerModeEffects  mode,
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
                                                  TileManager        *src1_tiles,
                                                  gint                x,
                                                  gint                y);
void            gimp_image_replace_image         (GimpImage          *gimage,
                                                  GimpDrawable       *drawable,
                                                  PixelRegion        *src2PR,
                                                  gboolean            undo,
                                                  gint                opacity,
                                                  PixelRegion        *maskPR,
                                                  gint                x,
                                                  gint                y);


/*  parasites  */

GimpParasite  * gimp_image_parasite_find         (const GimpImage    *gimage,
                                                  const gchar        *name);
gchar        ** gimp_image_parasite_list         (const GimpImage    *gimage,
                                                  gint               *count);
void            gimp_image_parasite_attach       (GimpImage          *gimage,
                                                  GimpParasite       *parasite);
void            gimp_image_parasite_detach       (GimpImage          *gimage,
                                                  const gchar        *parasite);


/*  tattoos  */

GimpTattoo      gimp_image_get_new_tattoo        (GimpImage          *gimage);
gboolean        gimp_image_set_tattoo_state      (GimpImage          *gimage,
                                                  GimpTattoo          val);
GimpTattoo      gimp_image_get_tattoo_state      (GimpImage          *gimage);


/*  layers / channels / paths  */

GimpContainer * gimp_image_get_layers            (const GimpImage    *gimage);
GimpContainer * gimp_image_get_channels          (const GimpImage    *gimage);

void            gimp_image_set_paths             (GimpImage          *gimage,
                                                  PathList           *paths);
PathList      * gimp_image_get_paths             (const GimpImage    *gimage);

GimpDrawable  * gimp_image_active_drawable       (const GimpImage    *gimage);
GimpLayer     * gimp_image_get_active_layer      (const GimpImage    *gimage);
GimpChannel   * gimp_image_get_active_channel    (const GimpImage    *gimage);

GimpLayer     * gimp_image_set_active_layer      (GimpImage          *gimage,
						  GimpLayer          *layer);
GimpChannel   * gimp_image_set_active_channel    (GimpImage          *gimage,
						  GimpChannel        *channel);
GimpChannel   * gimp_image_unset_active_channel  (GimpImage          *gimage);

gint            gimp_image_get_layer_index       (const GimpImage    *gimage,
						  const GimpLayer    *layer);
gint            gimp_image_get_channel_index     (const GimpImage    *gimage,
						  const GimpChannel  *channel);
GimpLayer     * gimp_image_get_layer_by_tattoo   (const GimpImage    *gimage,
						  GimpTattoo          tatoo);
GimpChannel   * gimp_image_get_channel_by_tattoo (const GimpImage    *gimage,
						  GimpTattoo          tatoo);
GimpChannel   * gimp_image_get_channel_by_name   (const GimpImage    *gimage,
						  const gchar        *name);

gboolean        gimp_image_add_layer             (GimpImage          *gimage,
						  GimpLayer          *layer,
						  gint                position);
void            gimp_image_remove_layer          (GimpImage          *gimage,
						  GimpLayer          *layer);

gboolean        gimp_image_raise_layer           (GimpImage          *gimage,
						  GimpLayer          *layer);
gboolean        gimp_image_lower_layer           (GimpImage          *gimage,
						  GimpLayer          *layer);
gboolean        gimp_image_raise_layer_to_top    (GimpImage          *gimage,
						  GimpLayer          *layer);
gboolean        gimp_image_lower_layer_to_bottom (GimpImage          *gimage,
						  GimpLayer          *layer);
gboolean        gimp_image_position_layer        (GimpImage          *gimage,
						  GimpLayer          *layer,
						  gint                new_index,
						  gboolean            push_undo);

gboolean        gimp_image_add_channel           (GimpImage          *gimage,
						  GimpChannel        *channel,
						  gint                position);
void            gimp_image_remove_channel        (GimpImage          *gimage,
						  GimpChannel        *channel);

gboolean        gimp_image_raise_channel         (GimpImage          *gimage,
						  GimpChannel        *channel);
gboolean        gimp_image_lower_channel         (GimpImage          *gimage,
						  GimpChannel        *channel);
gboolean        gimp_image_position_channel      (GimpImage          *gimage,
						  GimpChannel        *channel,
						  gint                new_index,
                                                  gboolean            push_undo);

gboolean        gimp_image_layer_boundary        (const GimpImage    *gimage,
						  BoundSeg          **segs,
						  gint               *n_segs);
GimpLayer     * gimp_image_pick_correlate_layer  (const GimpImage    *gimage,
						  gint                x,
						  gint                y);

void        gimp_image_invalidate_layer_previews (GimpImage          *gimage);
void      gimp_image_invalidate_channel_previews (GimpImage          *gimage);
444

445

446
#endif /* __GIMP_IMAGE_H__ */