gimpimage.h 28 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18 19
#ifndef __GIMP_IMAGE_H__
#define __GIMP_IMAGE_H__
20 21


22
#include "gimpviewable.h"
23

24

25
#define GIMP_IMAGE_TYPE_IS_RGB(t)          ((t) == GIMP_RGB_IMAGE ||         \
26
                                            (t) == GIMP_RGBA_IMAGE)
27
#define GIMP_IMAGE_TYPE_IS_GRAY(t)         ((t) == GIMP_GRAY_IMAGE ||        \
28
                                            (t) == GIMP_GRAYA_IMAGE)
29
#define GIMP_IMAGE_TYPE_IS_INDEXED(t)      ((t) == GIMP_INDEXED_IMAGE ||     \
30
                                            (t) == GIMP_INDEXEDA_IMAGE)
31

32
#define GIMP_IMAGE_TYPE_HAS_ALPHA(t)       ((t) == GIMP_RGBA_IMAGE  ||       \
33 34
                                            (t) == GIMP_GRAYA_IMAGE ||       \
                                            (t) == GIMP_INDEXEDA_IMAGE)
35

36 37 38 39 40 41 42 43 44
#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)
45 46 47 48 49 50 51 52 53
#define GIMP_IMAGE_TYPE_WITHOUT_ALPHA(t)  (((t) == GIMP_RGB_IMAGE ||         \
                                            (t) == GIMP_RGBA_IMAGE) ?        \
                                           GIMP_RGB_IMAGE :                  \
                                           ((t) == GIMP_GRAY_IMAGE ||        \
                                            (t) == GIMP_GRAYA_IMAGE) ?       \
                                           GIMP_GRAY_IMAGE :                 \
                                           ((t) == GIMP_INDEXED_IMAGE ||     \
                                            (t) == GIMP_INDEXEDA_IMAGE) ?    \
                                           GIMP_INDEXED_IMAGE : -1)
54 55 56 57 58 59
#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)
60 61 62 63 64 65 66 67 68
#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)
69 70 71 72 73 74 75

#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)
76

77

78 79 80
#define GIMP_IMAGE_ACTIVE_PARENT           ((gpointer) 1)


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
};

struct _GimpImageClass
99
{
100
  GimpViewableClass  parent_class;
101

102
  /*  signals  */
103 104 105 106 107 108 109
  void (* mode_changed)                 (GimpImage            *image);
  void (* alpha_changed)                (GimpImage            *image);
  void (* floating_selection_changed)   (GimpImage            *image);
  void (* active_layer_changed)         (GimpImage            *image);
  void (* active_channel_changed)       (GimpImage            *image);
  void (* active_vectors_changed)       (GimpImage            *image);
  void (* component_visibility_changed) (GimpImage            *image,
110
                                         GimpChannelType       channel);
111
  void (* component_active_changed)     (GimpImage            *image,
112
                                         GimpChannelType       channel);
113 114
  void (* mask_changed)                 (GimpImage            *image);
  void (* resolution_changed)           (GimpImage            *image);
115 116
  void (* size_changed_detailed)        (GimpImage            *image,
                                         gint                  previous_origin_x,
117 118 119
                                         gint                  previous_origin_y,
                                         gint                  previous_width,
                                         gint                  previous_height);
120 121 122
  void (* unit_changed)                 (GimpImage            *image);
  void (* quick_mask_changed)           (GimpImage            *image);
  void (* selection_control)            (GimpImage            *image,
123 124
                                         GimpSelectionControl  control);

125
  void (* clean)                        (GimpImage            *image,
126
                                         GimpDirtyMask         dirty_mask);
127
  void (* dirty)                        (GimpImage            *image,
128
                                         GimpDirtyMask         dirty_mask);
129 130
  void (* saved)                        (GimpImage            *image,
                                         const gchar          *uri);
131 132
  void (* exported)                     (GimpImage            *image,
                                         const gchar          *uri);
133

134 135 136 137 138 139
  void (* guide_added)                  (GimpImage            *image,
                                         GimpGuide            *guide);
  void (* guide_removed)                (GimpImage            *image,
                                         GimpGuide            *guide);
  void (* guide_moved)                  (GimpImage            *image,
                                         GimpGuide            *guide);
140
  void (* sample_point_added)           (GimpImage            *image,
141
                                         GimpSamplePoint      *sample_point);
142
  void (* sample_point_removed)         (GimpImage            *image,
143
                                         GimpSamplePoint      *sample_point);
144 145
  void (* sample_point_moved)           (GimpImage            *image,
                                         GimpSamplePoint      *sample_point);
146 147 148 149
  void (* parasite_attached)            (GimpImage            *image,
                                         const gchar          *name);
  void (* parasite_detached)            (GimpImage            *image,
                                         const gchar          *name);
150
  void (* colormap_changed)             (GimpImage            *image,
151
                                         gint                  color_index);
152
  void (* undo_event)                   (GimpImage            *image,
153
                                         GimpUndoEvent         event,
154
                                         GimpUndo             *undo);
155 156
};

157

158
GType           gimp_image_get_type              (void) G_GNUC_CONST;
159

160 161 162 163
GimpImage     * gimp_image_new                   (Gimp               *gimp,
                                                  gint                width,
                                                  gint                height,
                                                  GimpImageBaseType   base_type);
164

165
GimpImageBaseType  gimp_image_base_type            (const GimpImage  *image);
166
GimpImageType      gimp_image_base_type_with_alpha (const GimpImage  *image);
167 168 169
CombinationMode    gimp_image_get_combination_mode (GimpImageType     dest_type,
                                                    gint              src_bytes);

170
gint            gimp_image_get_ID                (const GimpImage    *image);
171 172 173
GimpImage     * gimp_image_get_by_ID             (Gimp               *gimp,
                                                  gint                id);

174
void            gimp_image_set_uri               (GimpImage          *image,
175
                                                  const gchar        *uri);
176
const gchar   * gimp_image_get_uri               (const GimpImage    *image);
177

178
void            gimp_image_set_filename          (GimpImage          *image,
179
                                                  const gchar        *filename);
180
gchar         * gimp_image_get_filename          (const GimpImage    *image);
181

182 183
const gchar   * gimp_image_get_display_name      (GimpImage          *image);

184 185 186
void            gimp_image_set_load_proc         (GimpImage          *image,
                                                  GimpPlugInProcedure *proc);
GimpPlugInProcedure * gimp_image_get_load_proc   (const GimpImage    *image);
187
void            gimp_image_set_save_proc         (GimpImage          *image,
188 189
                                                  GimpPlugInProcedure *proc);
GimpPlugInProcedure * gimp_image_get_save_proc   (const GimpImage    *image);
190 191
void            gimp_image_saved                 (GimpImage          *image,
                                                  const gchar        *uri);
192 193
void            gimp_image_exported              (GimpImage          *image,
                                                  const gchar        *uri);
194

195
void            gimp_image_set_resolution        (GimpImage          *image,
196 197
                                                  gdouble             xres,
                                                  gdouble             yres);
198
void            gimp_image_get_resolution        (const GimpImage    *image,
199 200
                                                  gdouble            *xres,
                                                  gdouble            *yres);
201
void            gimp_image_resolution_changed    (GimpImage          *image);
202

203
void            gimp_image_set_unit              (GimpImage          *image,
204
                                                  GimpUnit            unit);
205 206
GimpUnit        gimp_image_get_unit              (const GimpImage    *image);
void            gimp_image_unit_changed          (GimpImage          *image);
207

208 209
gint            gimp_image_get_width             (const GimpImage    *image);
gint            gimp_image_get_height            (const GimpImage    *image);
210

211 212
gboolean        gimp_image_has_alpha             (const GimpImage    *image);
gboolean        gimp_image_is_empty              (const GimpImage    *image);
213

214 215
void           gimp_image_set_floating_selection (GimpImage          *image,
                                                  GimpLayer          *floating_sel);
216
GimpLayer    * gimp_image_get_floating_selection (const GimpImage    *image);
217
void       gimp_image_floating_selection_changed (GimpImage          *image);
218

219 220
GimpChannel   * gimp_image_get_mask              (const GimpImage    *image);
void            gimp_image_mask_changed          (GimpImage          *image);
221

222 223 224

/*  image components  */

225
gint            gimp_image_get_component_index   (const GimpImage    *image,
226 227
                                                  GimpChannelType     channel);

228
void            gimp_image_set_component_active  (GimpImage          *image,
229 230
                                                  GimpChannelType     type,
                                                  gboolean            active);
231
gboolean        gimp_image_get_component_active  (const GimpImage    *image,
232
                                                  GimpChannelType     type);
233 234
void            gimp_image_get_active_array      (const GimpImage    *image,
                                                  gboolean           *components);
235

236
void            gimp_image_set_component_visible (GimpImage          *image,
237 238
                                                  GimpChannelType     type,
                                                  gboolean            visible);
239
gboolean        gimp_image_get_component_visible (const GimpImage    *image,
240
                                                  GimpChannelType     type);
241 242
void            gimp_image_get_visible_array     (const GimpImage    *image,
                                                  gboolean           *components);
243

244 245 246

/*  emitting image signals  */

247 248
void            gimp_image_mode_changed          (GimpImage          *image);
void            gimp_image_alpha_changed         (GimpImage          *image);
249
void            gimp_image_invalidate            (GimpImage          *image,
250 251 252 253
                                                  gint                x,
                                                  gint                y,
                                                  gint                width,
                                                  gint                height);
254 255 256 257 258 259 260
void            gimp_image_guide_added           (GimpImage          *image,
                                                  GimpGuide          *guide);
void            gimp_image_guide_removed         (GimpImage          *image,
                                                  GimpGuide          *guide);
void            gimp_image_guide_moved           (GimpImage          *image,
                                                  GimpGuide          *guide);

261
void            gimp_image_sample_point_added    (GimpImage          *image,
262
                                                  GimpSamplePoint    *sample_point);
263
void            gimp_image_sample_point_removed  (GimpImage          *image,
264
                                                  GimpSamplePoint    *sample_point);
265 266
void            gimp_image_sample_point_moved    (GimpImage          *image,
                                                  GimpSamplePoint    *sample_point);
267
void            gimp_image_colormap_changed      (GimpImage          *image,
268
                                                  gint                col);
269
void            gimp_image_selection_control     (GimpImage          *image,
270
                                                  GimpSelectionControl  control);
271
void            gimp_image_quick_mask_changed    (GimpImage          *image);
272 273
void            gimp_image_size_changed_detailed (GimpImage          *image,
                                                  gint                previous_origin_x,
274 275 276
                                                  gint                previous_origin_y,
                                                  gint                previous_width,
                                                  gint                previous_height);
277
void            gimp_image_undo_event            (GimpImage          *image,
278 279
                                                  GimpUndoEvent       event,
                                                  GimpUndo           *undo);
280 281 282 283


/*  dirty counters  */

284
gint            gimp_image_dirty                 (GimpImage          *image,
285
                                                  GimpDirtyMask       dirty_mask);
286
gint            gimp_image_clean                 (GimpImage          *image,
287
                                                  GimpDirtyMask       dirty_mask);
288
void            gimp_image_clean_all             (GimpImage          *image);
289
void            gimp_image_export_clean_all      (GimpImage          *image);
290
gint            gimp_image_is_dirty              (const GimpImage    *image);
291
gboolean        gimp_image_is_export_dirty       (const GimpImage    *image);
292
gint            gimp_image_get_dirty_time        (const GimpImage    *image);
293 294


295 296
/*  flush this image's displays  */

297
void            gimp_image_flush                 (GimpImage          *image);
298 299


300 301 302 303 304 305 306 307 308 309
/*  display / instance counters  */

gint            gimp_image_get_display_count     (const GimpImage    *image);
void            gimp_image_inc_display_count     (GimpImage          *image);
void            gimp_image_dec_display_count     (GimpImage          *image);

gint            gimp_image_get_instance_count    (const GimpImage    *image);
void            gimp_image_inc_instance_count    (GimpImage          *image);


310 311
/*  color transforms / utilities  */

312
void            gimp_image_get_foreground        (const GimpImage    *image,
313
                                                  GimpContext        *context,
314
                                                  GimpImageType       dest_type,
315
                                                  guchar             *fg);
316
void            gimp_image_get_background        (const GimpImage    *image,
317
                                                  GimpContext        *context,
318
                                                  GimpImageType       dest_type,
319
                                                  guchar             *bg);
320
void            gimp_image_get_color             (const GimpImage    *src_image,
321 322
                                                  GimpImageType       src_type,
                                                  const guchar       *src,
323
                                                  guchar             *rgba);
324
void            gimp_image_transform_rgb         (const GimpImage    *dest_image,
325
                                                  GimpImageType       dest_type,
326 327
                                                  const GimpRGB      *rgb,
                                                  guchar             *color);
328
void            gimp_image_transform_color       (const GimpImage    *dest_image,
329
                                                  GimpImageType       dest_type,
330
                                                  guchar             *dest,
331 332
                                                  GimpImageBaseType   src_type,
                                                  const guchar       *src);
333
TempBuf       * gimp_image_transform_temp_buf    (const GimpImage    *dest_image,
334
                                                  GimpImageType       dest_type,
335 336
                                                  TempBuf            *temp_buf,
                                                  gboolean           *new_buf);
337 338 339 340


/*  parasites  */

341
const GimpParasite * gimp_image_parasite_find    (const GimpImage    *image,
342
                                                  const gchar        *name);
343
gchar        ** gimp_image_parasite_list         (const GimpImage    *image,
344
                                                  gint               *count);
345
void            gimp_image_parasite_attach       (GimpImage          *image,
346
                                                  const GimpParasite *parasite);
347
void            gimp_image_parasite_detach       (GimpImage          *image,
348
                                                  const gchar        *name);
349 350 351 352


/*  tattoos  */

353 354
GimpTattoo      gimp_image_get_new_tattoo        (GimpImage          *image);
gboolean        gimp_image_set_tattoo_state      (GimpImage          *image,
355
                                                  GimpTattoo          val);
356
GimpTattoo      gimp_image_get_tattoo_state      (GimpImage          *image);
357 358


359 360 361 362 363
/*  projection  */

GimpProjection * gimp_image_get_projection       (const GimpImage    *image);


364
/*  layers / channels / vectors  */
365

366 367 368 369
GimpItemTree  * gimp_image_get_layer_tree        (const GimpImage    *image);
GimpItemTree  * gimp_image_get_channel_tree      (const GimpImage    *image);
GimpItemTree  * gimp_image_get_vectors_tree      (const GimpImage    *image);

370 371 372
GimpContainer * gimp_image_get_layers            (const GimpImage    *image);
GimpContainer * gimp_image_get_channels          (const GimpImage    *image);
GimpContainer * gimp_image_get_vectors           (const GimpImage    *image);
373

374 375 376 377
gint            gimp_image_get_n_layers          (const GimpImage    *image);
gint            gimp_image_get_n_channels        (const GimpImage    *image);
gint            gimp_image_get_n_vectors         (const GimpImage    *image);

378 379 380 381
GList         * gimp_image_get_layer_iter        (const GimpImage    *image);
GList         * gimp_image_get_channel_iter      (const GimpImage    *image);
GList         * gimp_image_get_vectors_iter      (const GimpImage    *image);

382 383 384 385
GList         * gimp_image_get_layer_list        (const GimpImage    *image);
GList         * gimp_image_get_channel_list      (const GimpImage    *image);
GList         * gimp_image_get_vectors_list      (const GimpImage    *image);

386
GimpDrawable  * gimp_image_get_active_drawable   (const GimpImage    *image);
387 388 389
GimpLayer     * gimp_image_get_active_layer      (const GimpImage    *image);
GimpChannel   * gimp_image_get_active_channel    (const GimpImage    *image);
GimpVectors   * gimp_image_get_active_vectors    (const GimpImage    *image);
390

391
GimpLayer     * gimp_image_set_active_layer      (GimpImage          *image,
392
                                                  GimpLayer          *layer);
393
GimpChannel   * gimp_image_set_active_channel    (GimpImage          *image,
394
                                                  GimpChannel        *channel);
395 396
GimpChannel   * gimp_image_unset_active_channel  (GimpImage          *image);
GimpVectors   * gimp_image_set_active_vectors    (GimpImage          *image,
Michael Natterer's avatar
Michael Natterer committed
397
                                                  GimpVectors        *vectors);
398

399
GimpLayer     * gimp_image_get_layer_by_tattoo   (const GimpImage    *image,
400
                                                  GimpTattoo          tattoo);
401
GimpChannel   * gimp_image_get_channel_by_tattoo (const GimpImage    *image,
402
                                                  GimpTattoo          tattoo);
403
GimpVectors   * gimp_image_get_vectors_by_tattoo (const GimpImage    *image,
404
                                                  GimpTattoo          tattoo);
Michael Natterer's avatar
Michael Natterer committed
405

406
GimpLayer     * gimp_image_get_layer_by_name     (const GimpImage    *image,
407
                                                  const gchar        *name);
408
GimpChannel   * gimp_image_get_channel_by_name   (const GimpImage    *image,
409
                                                  const gchar        *name);
410
GimpVectors   * gimp_image_get_vectors_by_name   (const GimpImage    *image,
411
                                                  const gchar        *name);
412

413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
gboolean        gimp_image_reorder_item          (GimpImage          *image,
                                                  GimpItem           *item,
                                                  GimpItem           *new_parent,
                                                  gint                new_index,
                                                  gboolean            push_undo,
                                                  const gchar        *undo_desc);
gboolean        gimp_image_raise_item            (GimpImage          *image,
                                                  GimpItem           *item,
                                                  GError            **error);
gboolean        gimp_image_raise_item_to_top     (GimpImage          *image,
                                                  GimpItem           *item);
gboolean        gimp_image_lower_item            (GimpImage          *image,
                                                  GimpItem           *item,
                                                  GError            **error);
gboolean        gimp_image_lower_item_to_bottom  (GimpImage          *image,
                                                  GimpItem           *item);

430
gboolean        gimp_image_add_layer             (GimpImage          *image,
431
                                                  GimpLayer          *layer,
432
                                                  GimpLayer          *parent,
433 434
                                                  gint                position,
                                                  gboolean            push_undo);
435
void            gimp_image_remove_layer          (GimpImage          *image,
436 437 438
                                                  GimpLayer          *layer,
                                                  gboolean            push_undo,
                                                  GimpLayer          *new_active);
439

440 441
void            gimp_image_add_layers            (GimpImage          *image,
                                                  GList              *layers,
442
                                                  GimpLayer          *parent,
443 444 445 446 447 448 449
                                                  gint                position,
                                                  gint                x,
                                                  gint                y,
                                                  gint                width,
                                                  gint                height,
                                                  const gchar        *undo_desc);

450
gboolean        gimp_image_add_channel           (GimpImage          *image,
451
                                                  GimpChannel        *channel,
452
                                                  GimpChannel        *parent,
453 454
                                                  gint                position,
                                                  gboolean            push_undo);
455
void            gimp_image_remove_channel        (GimpImage          *image,
456 457 458
                                                  GimpChannel        *channel,
                                                  gboolean            push_undo,
                                                  GimpChannel        *new_active);
459

460
gboolean        gimp_image_add_vectors           (GimpImage          *image,
461
                                                  GimpVectors        *vectors,
462
                                                  GimpVectors        *parent,
463 464
                                                  gint                position,
                                                  gboolean            push_undo);
465
void            gimp_image_remove_vectors        (GimpImage          *image,
466 467 468
                                                  GimpVectors        *vectors,
                                                  gboolean            push_undo,
                                                  GimpVectors        *new_active);
Michael Natterer's avatar
Michael Natterer committed
469

470 471 472 473
gboolean    gimp_image_coords_in_active_pickable (GimpImage          *image,
                                                  const GimpCoords   *coords,
                                                  gboolean            sample_merged,
                                                  gboolean            selected_only);
474

475
void            gimp_image_invalidate_previews   (GimpImage          *image);
476

477

478
#endif /* __GIMP_IMAGE_H__ */