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

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimppreviewarea.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:
43
43
#define DEFAULT_CHECK_SIZE  GIMP_CHECK_SIZE_MEDIUM_CHECKS
44
44
#define DEFAULT_CHECK_TYPE  GIMP_CHECK_TYPE_GRAY_CHECKS
45
45
 
 
46
#define CHECK_COLOR(area, row, col)        \
 
47
  (((((area)->offset_y + (row)) & size) ^  \
 
48
    (((area)->offset_x + (col)) & size)) ? dark : light)
46
49
 
47
 
static void      gimp_preview_area_class_init       (GimpPreviewAreaClass *klass);
48
 
static void      gimp_preview_area_init             (GimpPreviewArea *area);
49
50
 
50
51
static void      gimp_preview_area_finalize         (GObject         *object);
51
52
static void      gimp_preview_area_set_property     (GObject         *object,
70
71
static gint      gimp_preview_area_image_type_bytes (GimpImageType    type);
71
72
 
72
73
 
73
 
static GtkDrawingAreaClass *parent_class = NULL;
74
 
 
75
 
 
76
 
#define CHECK_COLOR(area, row, col)        \
77
 
  (((((area)->offset_y + (row)) & size) ^  \
78
 
    (((area)->offset_x + (col)) & size)) ? dark : light)
79
 
 
80
 
 
81
 
GType
82
 
gimp_preview_area_get_type (void)
83
 
{
84
 
  static GType view_type = 0;
85
 
 
86
 
  if (! view_type)
87
 
    {
88
 
      static const GTypeInfo view_info =
89
 
      {
90
 
        sizeof (GimpPreviewAreaClass),
91
 
        NULL,           /* base_init */
92
 
        NULL,           /* base_finalize */
93
 
        (GClassInitFunc) gimp_preview_area_class_init,
94
 
        NULL,           /* class_finalize */
95
 
        NULL,           /* class_data */
96
 
        sizeof (GimpPreviewArea),
97
 
        0,              /* n_preallocs */
98
 
        (GInstanceInitFunc) gimp_preview_area_init,
99
 
      };
100
 
 
101
 
      view_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
102
 
                                          "GimpPreviewArea",
103
 
                                          &view_info, 0);
104
 
    }
105
 
 
106
 
  return view_type;
107
 
}
 
74
G_DEFINE_TYPE (GimpPreviewArea, gimp_preview_area, GTK_TYPE_DRAWING_AREA)
 
75
 
 
76
#define parent_class gimp_preview_area_parent_class
 
77
 
108
78
 
109
79
static void
110
80
gimp_preview_area_class_init (GimpPreviewAreaClass *klass)
112
82
  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
113
83
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
114
84
 
115
 
  parent_class = g_type_class_peek_parent (klass);
116
 
 
117
85
  object_class->finalize      = gimp_preview_area_finalize;
118
86
  object_class->set_property  = gimp_preview_area_set_property;
119
87
  object_class->get_property  = gimp_preview_area_get_property;
126
94
                                                      _("Check Size"), NULL,
127
95
                                                      GIMP_TYPE_CHECK_SIZE,
128
96
                                                      DEFAULT_CHECK_SIZE,
129
 
                                                      G_PARAM_READWRITE));
 
97
                                                      GIMP_PARAM_READWRITE));
130
98
 
131
99
  g_object_class_install_property (object_class, PROP_CHECK_TYPE,
132
100
                                   g_param_spec_enum ("check-type",
133
101
                                                      _("Check Style"), NULL,
134
102
                                                      GIMP_TYPE_CHECK_TYPE,
135
103
                                                      DEFAULT_CHECK_TYPE,
136
 
                                                      G_PARAM_READWRITE));
 
104
                                                      GIMP_PARAM_READWRITE));
137
105
}
138
106
 
139
107
static void
333
301
/**
334
302
 * gimp_preview_area_new:
335
303
 *
 
304
 * Creates a new #GimpPreviewArea widget.
 
305
 *
336
306
 * Return value: a new #GimpPreviewArea widget.
337
307
 *
338
308
 * Since GIMP 2.2
377
347
  gint          col;
378
348
 
379
349
  g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
380
 
  g_return_if_fail (width > 0 && height > 0);
 
350
  g_return_if_fail (width >= 0 && height >= 0);
 
351
 
 
352
  if (width == 0 || height == 0)
 
353
    return;
 
354
 
381
355
  g_return_if_fail (buf != NULL);
382
356
  g_return_if_fail (rowstride > 0);
383
357
 
389
363
 
390
364
  if (x < 0)
391
365
    {
392
 
      gint  bpp = gimp_preview_area_image_type_bytes (type);
 
366
      gint bpp = gimp_preview_area_image_type_bytes (type);
393
367
 
394
 
      buf   -= x * bpp;
395
 
      width -= x;
 
368
      buf -= x * bpp;
 
369
      width += x;
396
370
 
397
371
      x = 0;
398
372
    }
402
376
 
403
377
  if (y < 0)
404
378
    {
405
 
      buf    -= y * rowstride;
406
 
      height -= y;
 
379
      buf -= y * rowstride;
 
380
      height += y;
407
381
 
408
382
      y = 0;
409
383
    }
635
609
  gint          i;
636
610
 
637
611
  g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
638
 
  g_return_if_fail (width > 0 && height > 0);
 
612
  g_return_if_fail (width >= 0 && height >= 0);
 
613
 
 
614
  if (width == 0 || height == 0)
 
615
    return;
 
616
 
639
617
  g_return_if_fail (buf1 != NULL);
640
618
  g_return_if_fail (buf2 != NULL);
641
619
  g_return_if_fail (rowstride1 > 0);
665
643
 
666
644
  if (x < 0)
667
645
    {
668
 
      gint  bpp = gimp_preview_area_image_type_bytes (type);
 
646
      gint bpp = gimp_preview_area_image_type_bytes (type);
669
647
 
670
 
      buf1  -= x * bpp;
671
 
      buf2  -= x * bpp;
672
 
      width -= x;
 
648
      buf1 -= x * bpp;
 
649
      buf2 -= x * bpp;
 
650
      width += x;
673
651
 
674
652
      x = 0;
675
653
    }
679
657
 
680
658
  if (y < 0)
681
659
    {
682
 
      buf1   -= y * rowstride1;
683
 
      buf2   -= y * rowstride2;
684
 
      height -= y;
 
660
      buf1 -= y * rowstride1;
 
661
      buf2 -= y * rowstride2;
 
662
      height += y;
685
663
 
686
664
      y = 0;
687
665
    }
818
796
 
819
797
          for (col = x; col < x + width; col++, s1 += 2, s2 += 2, d+= 3)
820
798
            {
821
 
              guchar inter[2];
 
799
              guchar inter[2] = { 0, };
822
800
 
823
801
              if (s1[1] == s2[1])
824
802
                {
1016
994
  gint          i;
1017
995
 
1018
996
  g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
1019
 
  g_return_if_fail (width > 0 && height > 0);
 
997
  g_return_if_fail (width >= 0 && height >= 0);
 
998
 
 
999
  if (width == 0 || height == 0)
 
1000
    return;
 
1001
 
1020
1002
  g_return_if_fail (buf1 != NULL);
1021
1003
  g_return_if_fail (buf2 != NULL);
1022
1004
  g_return_if_fail (mask != NULL);
1032
1014
 
1033
1015
  if (x < 0)
1034
1016
    {
1035
 
      gint  bpp = gimp_preview_area_image_type_bytes (type);
 
1017
      gint bpp = gimp_preview_area_image_type_bytes (type);
1036
1018
 
1037
 
      buf1  -= x * bpp;
1038
 
      buf2  -= x * bpp;
1039
 
      mask  -= x;
1040
 
      width -= x;
 
1019
      buf1 -= x * bpp;
 
1020
      buf2 -= x * bpp;
 
1021
      mask -= x;
 
1022
      width += x;
1041
1023
 
1042
1024
      x = 0;
1043
1025
    }
1047
1029
 
1048
1030
  if (y < 0)
1049
1031
    {
1050
 
      buf1   -= y * rowstride1;
1051
 
      buf2   -= y * rowstride2;
1052
 
      mask   -= y * rowstride_mask;
1053
 
      height -= y;
 
1032
      buf1 -= y * rowstride1;
 
1033
      buf2 -= y * rowstride2;
 
1034
      mask -= y * rowstride_mask;
 
1035
      height += y;
1054
1036
 
1055
1037
      y = 0;
1056
1038
    }
1304
1286
 
1305
1287
                default:
1306
1288
                  {
1307
 
                    guchar inter[2];
 
1289
                    guchar inter[2] = { 0, };
1308
1290
 
1309
1291
                    if (s1[1] == s2[1])
1310
1292
                      {
1529
1511
 * @area:   a #GimpPreviewArea widget.
1530
1512
 * @x:      x offset in preview
1531
1513
 * @y:      y offset in preview
1532
 
 * @width:  buffer width
1533
 
 * @height: buffer height
 
1514
 * @width:  width of the rectangle to fill
 
1515
 * @height: height of the rectangle to fill
1534
1516
 * @red:    red component of the fill color (0-255)
1535
1517
 * @green:  green component of the fill color (0-255)
1536
1518
 * @blue:   red component of the fill color (0-255)
1537
1519
 *
1538
 
 * Fills @area in the given color and queues a redraw on the given
1539
 
 * rectangle.
 
1520
 * Fills the given rectangle of @area in the given color and queues a
 
1521
 * redraw.
1540
1522
 *
1541
1523
 * Since GIMP 2.2
1542
1524
 **/
1556
1538
  gint    col;
1557
1539
 
1558
1540
  g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
1559
 
  g_return_if_fail (width > 0 && height > 0);
 
1541
  g_return_if_fail (width >= 0 && height >= 0);
 
1542
 
 
1543
  if (width == 0 || height == 0)
 
1544
    return;
1560
1545
 
1561
1546
  if (x + width < 0 || x >= area->width)
1562
1547
    return;
1566
1551
 
1567
1552
  if (x < 0)
1568
1553
    {
1569
 
      width -= x;
 
1554
      width += x;
1570
1555
      x = 0;
1571
1556
    }
1572
1557
 
1575
1560
 
1576
1561
  if (y < 0)
1577
1562
    {
1578
 
      height -= y;
 
1563
      height += y;
1579
1564
      y = 0;
1580
1565
    }
1581
1566