~ubuntu-branches/ubuntu/intrepid/gimp/intrepid-backports

« back to all changes in this revision

Viewing changes to app/display/gimpdisplayshell-transform.c

  • Committer: Bazaar Package Importer
  • Author(s): Bartosz
  • Date: 2009-01-09 16:24:23 UTC
  • mfrom: (38.1.1 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090109162423-rsr8ky4mzv8irpf8
Tags: 2.6.3-1ubuntu1~intrepid1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
                                         GimpCoords             *image_coords,
50
50
                                         GimpCoords             *display_coords)
51
51
{
52
 
  gint scaled_viewport_offset_x;
53
 
  gint scaled_viewport_offset_y;
54
 
 
55
52
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
56
53
  g_return_if_fail (image_coords != NULL);
57
54
  g_return_if_fail (display_coords != NULL);
61
58
  display_coords->x = SCALEX (shell, image_coords->x);
62
59
  display_coords->y = SCALEY (shell, image_coords->y);
63
60
 
64
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
65
 
                                                        &scaled_viewport_offset_x,
66
 
                                                        &scaled_viewport_offset_y);
67
 
 
68
 
  display_coords->x += scaled_viewport_offset_x;
69
 
  display_coords->y += scaled_viewport_offset_y;
 
61
  display_coords->x -= shell->offset_x;
 
62
  display_coords->y -= shell->offset_y;
70
63
}
71
64
 
72
65
/**
83
76
                                           GimpCoords             *display_coords,
84
77
                                           GimpCoords             *image_coords)
85
78
{
86
 
  gint scaled_viewport_offset_x;
87
 
  gint scaled_viewport_offset_y;
88
 
 
89
79
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
90
80
  g_return_if_fail (display_coords != NULL);
91
81
  g_return_if_fail (image_coords != NULL);
92
82
 
93
83
  *image_coords = *display_coords;
94
84
 
95
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
96
 
                                                        &scaled_viewport_offset_x,
97
 
                                                        &scaled_viewport_offset_y);
98
 
 
99
 
  image_coords->x = display_coords->x - scaled_viewport_offset_x;
100
 
  image_coords->y = display_coords->y - scaled_viewport_offset_y;
 
85
  image_coords->x = display_coords->x + shell->offset_x;
 
86
  image_coords->y = display_coords->y + shell->offset_y;
101
87
 
102
88
  image_coords->x /= shell->scale_x;
103
89
  image_coords->y /= shell->scale_y;
111
97
                                 gint                   *ny,
112
98
                                 gboolean                use_offsets)
113
99
{
114
 
  gint   scaled_viewport_offset_x;
115
 
  gint   scaled_viewport_offset_y;
116
100
  gint   offset_x = 0;
117
101
  gint   offset_y = 0;
118
102
  gint64 tx;
136
120
  tx = ((gint64) x * shell->x_src_dec) / shell->x_dest_inc;
137
121
  ty = ((gint64) y * shell->y_src_dec) / shell->y_dest_inc;
138
122
 
139
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
140
 
                                                        &scaled_viewport_offset_x,
141
 
                                                        &scaled_viewport_offset_y);
142
 
  tx += scaled_viewport_offset_x;
143
 
  ty += scaled_viewport_offset_y;
 
123
  tx -= shell->offset_x;
 
124
  ty -= shell->offset_y;
144
125
 
145
126
  /* The projected coordinates might overflow a gint in the case of big
146
127
     images at high zoom levels, so we clamp them here to avoid problems.  */
173
154
                                   gboolean                round,
174
155
                                   gboolean                use_offsets)
175
156
{
176
 
  gint   scaled_viewport_offset_x;
177
 
  gint   scaled_viewport_offset_y;
178
157
  gint   offset_x = 0;
179
158
  gint   offset_y = 0;
180
159
  gint64 tx;
192
171
      gimp_item_offsets (item, &offset_x, &offset_y);
193
172
    }
194
173
 
195
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
196
 
                                                        &scaled_viewport_offset_x,
197
 
                                                        &scaled_viewport_offset_y);
198
 
  tx = (gint64) x - scaled_viewport_offset_x;
199
 
  ty = (gint64) y - scaled_viewport_offset_y;
 
174
  tx = (gint64) x + shell->offset_x;
 
175
  ty = (gint64) y + shell->offset_y;
200
176
 
201
177
  tx *= shell->x_dest_inc;
202
178
  ty *= shell->y_dest_inc;
232
208
                                    gdouble                *ny,
233
209
                                    gboolean                use_offsets)
234
210
{
235
 
  gint scaled_viewport_offset_x;
236
 
  gint scaled_viewport_offset_y;
237
211
  gint offset_x = 0;
238
212
  gint offset_y = 0;
239
213
 
249
223
      gimp_item_offsets (item, &offset_x, &offset_y);
250
224
    }
251
225
 
252
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
253
 
                                                        &scaled_viewport_offset_x,
254
 
                                                        &scaled_viewport_offset_y);
255
 
 
256
 
  *nx = SCALEX (shell, x + offset_x) + scaled_viewport_offset_x;
257
 
  *ny = SCALEY (shell, y + offset_y) + scaled_viewport_offset_y;
 
226
  *nx = SCALEX (shell, x + offset_x) - shell->offset_x;
 
227
  *ny = SCALEY (shell, y + offset_y) - shell->offset_y;
258
228
}
259
229
 
260
230
/**
279
249
                                     gdouble                *ny,
280
250
                                     gboolean                use_offsets)
281
251
{
282
 
  gint scaled_viewport_offset_x;
283
 
  gint scaled_viewport_offset_y;
284
252
  gint offset_x = 0;
285
253
  gint offset_y = 0;
286
254
 
296
264
      gimp_item_offsets (item, &offset_x, &offset_y);
297
265
    }
298
266
 
299
 
  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
300
 
                                                        &scaled_viewport_offset_x,
301
 
                                                        &scaled_viewport_offset_y);
302
 
 
303
 
  *nx = (x - scaled_viewport_offset_x) / shell->scale_x - offset_x;
304
 
  *ny = (y - scaled_viewport_offset_y) / shell->scale_y - offset_y;
 
267
  *nx = (x + shell->offset_x) / shell->scale_x - offset_x;
 
268
  *ny = (y + shell->offset_y) / shell->scale_y - offset_y;
305
269
}
306
270
 
307
271
/**
339
303
 
340
304
  for (i = 0; i < n_points ; i++)
341
305
    {
342
 
      gint    scaled_viewport_offset_x;
343
 
      gint    scaled_viewport_offset_y;
344
306
      gdouble x = points[i].x + offset_x;
345
307
      gdouble y = points[i].y + offset_y;
346
308
 
347
309
      x = x * shell->x_src_dec / shell->x_dest_inc;
348
310
      y = y * shell->y_src_dec / shell->y_dest_inc;
349
311
 
350
 
      gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
351
 
                                                            &scaled_viewport_offset_x,
352
 
                                                            &scaled_viewport_offset_y);
353
 
 
354
 
      coords[i].x = CLAMP (PROJ_ROUND64 (x) + scaled_viewport_offset_x,
 
312
      coords[i].x = CLAMP (PROJ_ROUND64 (x) - shell->offset_x,
355
313
                           G_MININT, G_MAXINT);
356
 
      coords[i].y = CLAMP (PROJ_ROUND64 (y) + scaled_viewport_offset_y,
 
314
      coords[i].y = CLAMP (PROJ_ROUND64 (y) - shell->offset_y,
357
315
                           G_MININT, G_MAXINT);
358
316
    }
359
317
}
393
351
 
394
352
  for (i = 0; i < n_coords ; i++)
395
353
    {
396
 
      gint    scaled_viewport_offset_x;
397
 
      gint    scaled_viewport_offset_y;
398
354
      gdouble x = image_coords[i].x + offset_x;
399
355
      gdouble y = image_coords[i].y + offset_y;
400
356
 
401
357
      x = x * shell->x_src_dec / shell->x_dest_inc;
402
358
      y = y * shell->y_src_dec / shell->y_dest_inc;
403
359
 
404
 
      gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
405
 
                                                            &scaled_viewport_offset_x,
406
 
                                                            &scaled_viewport_offset_y);
407
 
 
408
 
      disp_coords[i].x = CLAMP (PROJ_ROUND64 (x) + scaled_viewport_offset_x,
 
360
      disp_coords[i].x = CLAMP (PROJ_ROUND64 (x) - shell->offset_x,
409
361
                                G_MININT, G_MAXINT);
410
 
      disp_coords[i].y = CLAMP (PROJ_ROUND64 (y) + scaled_viewport_offset_y,
 
362
      disp_coords[i].y = CLAMP (PROJ_ROUND64 (y) - shell->offset_y,
411
363
                                G_MININT, G_MAXINT);
412
364
    }
413
365
}
447
399
 
448
400
  for (i = 0; i < n_segs ; i++)
449
401
    {
450
 
      gint   scaled_viewport_offset_x;
451
 
      gint   scaled_viewport_offset_y;
452
402
      gint64 x1, x2;
453
403
      gint64 y1, y2;
454
404
 
462
412
      y1 = (y1 * shell->y_src_dec) / shell->y_dest_inc;
463
413
      y2 = (y2 * shell->y_src_dec) / shell->y_dest_inc;
464
414
 
465
 
      gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
466
 
                                                            &scaled_viewport_offset_x,
467
 
                                                            &scaled_viewport_offset_y);
468
 
 
469
 
      dest_segs[i].x1 = CLAMP (x1 + scaled_viewport_offset_x,
470
 
                               G_MININT, G_MAXINT);
471
 
      dest_segs[i].x2 = CLAMP (x2 + scaled_viewport_offset_x,
472
 
                               G_MININT, G_MAXINT);
473
 
      dest_segs[i].y1 = CLAMP (y1 + scaled_viewport_offset_y,
474
 
                               G_MININT, G_MAXINT);
475
 
      dest_segs[i].y2 = CLAMP (y2 + scaled_viewport_offset_y,
476
 
                               G_MININT, G_MAXINT);
 
415
      dest_segs[i].x1 = CLAMP (x1 - shell->offset_x, G_MININT, G_MAXINT);
 
416
      dest_segs[i].x2 = CLAMP (x2 - shell->offset_x, G_MININT, G_MAXINT);
 
417
      dest_segs[i].y1 = CLAMP (y1 - shell->offset_y, G_MININT, G_MAXINT);
 
418
      dest_segs[i].y2 = CLAMP (y2 - shell->offset_y, G_MININT, G_MAXINT);
477
419
    }
478
420
}
479
421