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

« back to all changes in this revision

Viewing changes to app/base/threshold.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
27
27
 
28
28
 
29
29
void
30
 
threshold_2 (gpointer     data,
31
 
             PixelRegion *srcPR,
32
 
             PixelRegion *destPR)
33
 
{
34
 
  threshold (srcPR, destPR, data);
35
 
}
36
 
 
37
 
void
38
 
threshold (PixelRegion *srcPR,
39
 
           PixelRegion *destPR,
40
 
           gpointer     data)
41
 
{
42
 
  Threshold *tr;
43
 
  guchar    *src, *s;
44
 
  guchar    *dest, *d;
45
 
  gint       has_alpha, alpha;
46
 
  gint       w, h, b;
47
 
  gint       value;
48
 
 
49
 
  tr = (Threshold *) data;
 
30
threshold (Threshold   *tr,
 
31
           PixelRegion *srcPR,
 
32
           PixelRegion *destPR)
 
33
{
 
34
  const guchar *src, *s;
 
35
  guchar       *dest, *d;
 
36
  gboolean      has_alpha;
 
37
  gint          alpha;
 
38
  gint          w, h, b;
 
39
  gint          value;
50
40
 
51
41
  h         = srcPR->h;
52
42
  src       = srcPR->data;
61
51
      d = dest;
62
52
 
63
53
      while (w--)
64
 
        {
65
 
          if (tr->color)
66
 
            {
67
 
              value = MAX (s[RED_PIX], s[GREEN_PIX]);
68
 
              value = MAX (value, s[BLUE_PIX]);
69
 
 
70
 
              value = (value >= tr->low_threshold && value <= tr->high_threshold ) ? 255 : 0;
71
 
            }
72
 
          else
73
 
            value = (s[GRAY_PIX] >= tr->low_threshold && s[GRAY_PIX] <= tr->high_threshold) ? 255 : 0;
74
 
 
75
 
          for (b = 0; b < alpha; b++)
76
 
            d[b] = value;
77
 
 
78
 
          if (has_alpha)
79
 
            d[alpha] = s[alpha];
80
 
 
81
 
          s += srcPR->bytes;
82
 
          d += destPR->bytes;
83
 
        }
 
54
        {
 
55
          if (tr->color)
 
56
            {
 
57
              value = MAX (s[RED_PIX], s[GREEN_PIX]);
 
58
              value = MAX (value, s[BLUE_PIX]);
 
59
 
 
60
              value = (value >= tr->low_threshold &&
 
61
                       value <= tr->high_threshold ) ? 255 : 0;
 
62
            }
 
63
          else
 
64
            {
 
65
              value = (s[GRAY_PIX] >= tr->low_threshold &&
 
66
                       s[GRAY_PIX] <= tr->high_threshold) ? 255 : 0;
 
67
            }
 
68
 
 
69
          for (b = 0; b < alpha; b++)
 
70
            d[b] = value;
 
71
 
 
72
          if (has_alpha)
 
73
            d[alpha] = s[alpha];
 
74
 
 
75
          s += srcPR->bytes;
 
76
          d += destPR->bytes;
 
77
        }
84
78
 
85
79
      src  += srcPR->rowstride;
86
80
      dest += destPR->rowstride;