~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimpimage-flip.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
24
24
 
25
25
#include "gimp.h"
26
26
#include "gimpcontext.h"
 
27
#include "gimpguide.h"
27
28
#include "gimpimage.h"
28
29
#include "gimpimage-flip.h"
29
30
#include "gimpimage-guides.h"
 
31
#include "gimpimage-sample-points.h"
30
32
#include "gimpimage-undo.h"
31
33
#include "gimpimage-undo-push.h"
32
34
#include "gimpitem.h"
33
35
#include "gimplist.h"
34
36
#include "gimpprogress.h"
 
37
#include "gimpsamplepoint.h"
35
38
 
36
39
 
37
40
void
38
 
gimp_image_flip (GimpImage           *gimage,
 
41
gimp_image_flip (GimpImage           *image,
39
42
                 GimpContext         *context,
40
43
                 GimpOrientationType  flip_type,
41
44
                 GimpProgress        *progress)
42
45
{
43
 
  GimpItem *item;
44
 
  GList    *list;
45
 
  gdouble   axis;
46
 
  gdouble   progress_max;
47
 
  gdouble   progress_current = 1.0;
 
46
  GList   *list;
 
47
  gdouble  axis;
 
48
  gdouble  progress_max;
 
49
  gdouble  progress_current = 1.0;
48
50
 
49
 
  g_return_if_fail (GIMP_IS_IMAGE (gimage));
 
51
  g_return_if_fail (GIMP_IS_IMAGE (image));
50
52
  g_return_if_fail (GIMP_IS_CONTEXT (context));
51
53
  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
52
54
 
53
 
  gimp_set_busy (gimage->gimp);
 
55
  gimp_set_busy (image->gimp);
54
56
 
55
57
  switch (flip_type)
56
58
    {
57
59
    case GIMP_ORIENTATION_HORIZONTAL:
58
 
      axis = (gdouble) gimage->width / 2.0;
 
60
      axis = (gdouble) image->width / 2.0;
59
61
      break;
60
62
 
61
63
    case GIMP_ORIENTATION_VERTICAL:
62
 
      axis = (gdouble) gimage->height / 2.0;
 
64
      axis = (gdouble) image->height / 2.0;
63
65
      break;
64
66
 
65
67
    default:
67
69
      return;
68
70
    }
69
71
 
70
 
  progress_max = (gimage->channels->num_children +
71
 
                  gimage->layers->num_children   +
72
 
                  gimage->vectors->num_children  +
 
72
  progress_max = (image->channels->num_children +
 
73
                  image->layers->num_children   +
 
74
                  image->vectors->num_children  +
73
75
                  1 /* selection */);
74
76
 
75
 
  gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_FLIP, NULL);
 
77
  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_FLIP, NULL);
76
78
 
77
79
  /*  Flip all channels  */
78
 
  for (list = GIMP_LIST (gimage->channels)->list;
 
80
  for (list = GIMP_LIST (image->channels)->list;
79
81
       list;
80
82
       list = g_list_next (list))
81
83
    {
82
 
      item = (GimpItem *) list->data;
 
84
      GimpItem *item = list->data;
83
85
 
84
86
      gimp_item_flip (item, context, flip_type, axis, TRUE);
85
87
 
88
90
    }
89
91
 
90
92
  /*  Flip all vectors  */
91
 
  for (list = GIMP_LIST (gimage->vectors)->list;
 
93
  for (list = GIMP_LIST (image->vectors)->list;
92
94
       list;
93
95
       list = g_list_next (list))
94
96
    {
95
 
      item = (GimpItem *) list->data;
 
97
      GimpItem *item = list->data;
96
98
 
97
99
      gimp_item_flip (item, context, flip_type, axis, FALSE);
98
100
 
101
103
    }
102
104
 
103
105
  /*  Don't forget the selection mask!  */
104
 
  gimp_item_flip (GIMP_ITEM (gimp_image_get_mask (gimage)), context,
 
106
  gimp_item_flip (GIMP_ITEM (gimp_image_get_mask (image)), context,
105
107
                  flip_type, axis, TRUE);
106
108
 
107
109
  if (progress)
108
110
    gimp_progress_set_value (progress, progress_current++ / progress_max);
109
111
 
110
112
  /*  Flip all layers  */
111
 
  for (list = GIMP_LIST (gimage->layers)->list;
 
113
  for (list = GIMP_LIST (image->layers)->list;
112
114
       list;
113
115
       list = g_list_next (list))
114
116
    {
115
 
      item = (GimpItem *) list->data;
 
117
      GimpItem *item = list->data;
116
118
 
117
119
      gimp_item_flip (item, context, flip_type, axis, FALSE);
118
120
 
121
123
    }
122
124
 
123
125
  /*  Flip all Guides  */
124
 
  for (list = gimage->guides; list; list = g_list_next (list))
 
126
  for (list = image->guides; list; list = g_list_next (list))
125
127
    {
126
 
      GimpGuide *guide = list->data;
 
128
      GimpGuide *guide    = list->data;
 
129
      gint       position = gimp_guide_get_position (guide);
127
130
 
128
 
      switch (guide->orientation)
129
 
        {
130
 
        case GIMP_ORIENTATION_HORIZONTAL:
 
131
      switch (gimp_guide_get_orientation (guide))
 
132
        {
 
133
        case GIMP_ORIENTATION_HORIZONTAL:
131
134
          if (flip_type == GIMP_ORIENTATION_VERTICAL)
132
 
            gimp_image_move_guide (gimage, guide,
133
 
                                   gimage->height - guide->position, TRUE);
134
 
          break;
 
135
            gimp_image_move_guide (image, guide,
 
136
                                   image->height - position, TRUE);
 
137
          break;
135
138
 
136
 
        case GIMP_ORIENTATION_VERTICAL:
 
139
        case GIMP_ORIENTATION_VERTICAL:
137
140
          if (flip_type == GIMP_ORIENTATION_HORIZONTAL)
138
 
            gimp_image_move_guide (gimage, guide,
139
 
                                   gimage->width - guide->position, TRUE);
140
 
          break;
141
 
 
142
 
        default:
143
 
          break;
144
 
        }
145
 
    }
146
 
 
147
 
  gimp_image_undo_group_end (gimage);
148
 
 
149
 
  gimp_unset_busy (gimage->gimp);
 
141
            gimp_image_move_guide (image, guide,
 
142
                                   image->width - position, TRUE);
 
143
          break;
 
144
 
 
145
        default:
 
146
          break;
 
147
        }
 
148
    }
 
149
 
 
150
  /*  Flip all sample points  */
 
151
  for (list = image->sample_points; list; list = g_list_next (list))
 
152
    {
 
153
      GimpSamplePoint *sample_point = list->data;
 
154
 
 
155
      if (flip_type == GIMP_ORIENTATION_VERTICAL)
 
156
        gimp_image_move_sample_point (image, sample_point,
 
157
                                      sample_point->x,
 
158
                                      image->height - sample_point->y,
 
159
                                      TRUE);
 
160
 
 
161
      if (flip_type == GIMP_ORIENTATION_HORIZONTAL)
 
162
        gimp_image_move_sample_point (image, sample_point,
 
163
                                      image->width - sample_point->x,
 
164
                                      sample_point->y,
 
165
                                      TRUE);
 
166
    }
 
167
 
 
168
  gimp_image_undo_group_end (image);
 
169
 
 
170
  gimp_unset_busy (image->gimp);
150
171
}