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

« back to all changes in this revision

Viewing changes to tools/kernelgen.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
 * kernelgen -- Copyright (C) 2000 Sven Neumann <sven@gimp.org>
38
38
 
39
39
static void
40
40
create_kernel (double x,
41
 
               double y)
 
41
               double y)
42
42
{
43
43
  double value[KERNEL_WIDTH][KERNEL_HEIGHT];
44
44
  double dist_x;
58
58
      dist_y = y - (((double)j + 0.5) / (double)STEPS);
59
59
 
60
60
      for (i = 0; i < STEPS * KERNEL_WIDTH; i++)
61
 
        {
62
 
          dist_x = x - (((double) i + 0.5) / (double) STEPS);
63
 
 
64
 
          /*  I've tried to use a gauss function here instead of a
65
 
              threshold, but the result was not that impressive.    */
66
 
          w = (SQR (dist_x) + SQR (dist_y)) < THRESHOLD ? 1.0 : 0.0;
67
 
 
68
 
          value[i / STEPS][j / STEPS] += w;
69
 
          sum += w;
70
 
        }
 
61
        {
 
62
          dist_x = x - (((double) i + 0.5) / (double) STEPS);
 
63
 
 
64
          /*  I've tried to use a gauss function here instead of a
 
65
              threshold, but the result was not that impressive.    */
 
66
          w = (SQR (dist_x) + SQR (dist_y)) < THRESHOLD ? 1.0 : 0.0;
 
67
 
 
68
          value[i / STEPS][j / STEPS] += w;
 
69
          sum += w;
 
70
        }
71
71
    }
72
72
 
73
73
  for (j = 0; j < KERNEL_HEIGHT; j++)
74
74
    {
75
75
      for (i = 0; i < KERNEL_WIDTH; i++)
76
 
        {
77
 
          w = (double) KERNEL_SUM * value[i][j] / sum;
78
 
          printf (" %3d,", (int) (w + 0.5));
79
 
        }
 
76
        {
 
77
          w = (double) KERNEL_SUM * value[i][j] / sum;
 
78
          printf (" %3d,", (int) (w + 0.5));
 
79
        }
80
80
    }
81
81
}
82
82
 
88
88
  double x, y;
89
89
 
90
90
  printf ("/* gimpbrushcore-kernels.h\n"
91
 
          " *\n"
92
 
          " *   This file was generated using kernelgen as found in the tools dir.\n");
 
91
          " *\n"
 
92
          " *   This file was generated using kernelgen as found in the tools dir.\n");
93
93
  printf (" *   (threshold = %g)\n", THRESHOLD);
94
94
  printf (" */\n\n");
95
95
  printf ("#ifndef __GIMP_BRUSH_CORE_KERNELS_H__\n");
101
101
  printf ("\n\n");
102
102
  printf ("/*  Brush pixel subsampling kernels  */\n");
103
103
  printf ("static const int subsample[%d][%d][%d] =\n{\n",
104
 
          SUBSAMPLE + 1, SUBSAMPLE + 1, KERNEL_WIDTH * KERNEL_HEIGHT);
 
104
          SUBSAMPLE + 1, SUBSAMPLE + 1, KERNEL_WIDTH * KERNEL_HEIGHT);
105
105
 
106
106
  for (j = 0; j <= SUBSAMPLE; j++)
107
107
    {
110
110
      printf ("  {\n");
111
111
 
112
112
      for (i = 0; i <= SUBSAMPLE; i++)
113
 
        {
114
 
          x = (double) i / (double) SUBSAMPLE;
 
113
        {
 
114
          x = (double) i / (double) SUBSAMPLE;
115
115
 
116
 
          printf ("    {");
117
 
          create_kernel (x, y);
118
 
          printf (" }%s", i < SUBSAMPLE ? ",\n" : "\n");
119
 
        }
 
116
          printf ("    {");
 
117
          create_kernel (x, y);
 
118
          printf (" }%s", i < SUBSAMPLE ? ",\n" : "\n");
 
119
        }
120
120
 
121
121
      printf ("  }%s", j < SUBSAMPLE ? ",\n" : "\n");
122
122
    }