app/gimage_mask.c applied patch from Ben Jackson to fix fractional pixel

* app/gimage_mask.c
* app/paint_core.c: applied patch from Ben Jackson to fix fractional pixel
errors and reverted the old fix.

* app/paint_funcs.h: changed the #defines for ERASE_MODE and REPLACE_MODE to
correctly match layer_modes[]

-Yosh
This commit is contained in:
Manish Singh 1998-03-24 02:18:58 +00:00
parent a705770e83
commit 09a5fde1ce
7 changed files with 103 additions and 118 deletions

View File

@ -1,3 +1,12 @@
Mon Mar 23 18:08:59 PST 1998 Manish Singh <yosh@gimp.org>
* app/gimage_mask.c
* app/paint_core.c: applied patch from Ben Jackson to fix
fractional pixel errors and reverted the old fix.
* app/paint_funcs.h: changed the #defines for ERASE_MODE and
REPLACE_MODE to correctly match layer_modes[]
Mon Mar 23 20:51:53 1998 Owen Taylor <owt1@cornell.edu>
* INSTALL configure.in: Added some documentation

View File

@ -573,33 +573,16 @@ gimage_mask_stroke (gimage, drawable)
non_gui_paint_core.paint_func = gimage_mask_stroke_paint_func;
gimage_mask_stroking = TRUE;
/* Note added by Raph Levien, 27 Jan 1998
The subtraction of 0.125 is to compensate for imprecision in
paint_core_subsample_mask. Ben Jackson posted a patch on 14 Jan
1998 to gimp-developers which addresses the imprecision more
directly. However, I've chosen this quick hack instead because it
is a less drastic change, and has no impact on performance. By
contrast, Ben's patch builds 25 rather than 16 subsampled brush
masks.
I'm planning to rework the subsample mechanism anyway to make way
for the natural brushes. When that happens, I'll be sure to make
it round precisely, at which point these -0.125 offsets can come
out.
*/
non_gui_paint_core.startx = non_gui_paint_core.lastx = (stroke_segs[0].x1 - offx) - 0.125;
non_gui_paint_core.starty = non_gui_paint_core.lasty = (stroke_segs[0].y1 - offy) - 0.125;
non_gui_paint_core.startx = non_gui_paint_core.lastx = (stroke_segs[0].x1 - offx);
non_gui_paint_core.starty = non_gui_paint_core.lasty = (stroke_segs[0].y1 - offy);
seg = 0;
for (i = 0; i < num_strokes; i++)
{
while (stroke_segs[seg].x2 != -1)
{
non_gui_paint_core.curx = (stroke_segs[seg].x2 - offx - 0.125);
non_gui_paint_core.cury = (stroke_segs[seg].y2 - offy - 0.125);
non_gui_paint_core.curx = (stroke_segs[seg].x2 - offx);
non_gui_paint_core.cury = (stroke_segs[seg].y2 - offy);
paint_core_interpolate (&non_gui_paint_core, drawable);

View File

@ -573,33 +573,16 @@ gimage_mask_stroke (gimage, drawable)
non_gui_paint_core.paint_func = gimage_mask_stroke_paint_func;
gimage_mask_stroking = TRUE;
/* Note added by Raph Levien, 27 Jan 1998
The subtraction of 0.125 is to compensate for imprecision in
paint_core_subsample_mask. Ben Jackson posted a patch on 14 Jan
1998 to gimp-developers which addresses the imprecision more
directly. However, I've chosen this quick hack instead because it
is a less drastic change, and has no impact on performance. By
contrast, Ben's patch builds 25 rather than 16 subsampled brush
masks.
I'm planning to rework the subsample mechanism anyway to make way
for the natural brushes. When that happens, I'll be sure to make
it round precisely, at which point these -0.125 offsets can come
out.
*/
non_gui_paint_core.startx = non_gui_paint_core.lastx = (stroke_segs[0].x1 - offx) - 0.125;
non_gui_paint_core.starty = non_gui_paint_core.lasty = (stroke_segs[0].y1 - offy) - 0.125;
non_gui_paint_core.startx = non_gui_paint_core.lastx = (stroke_segs[0].x1 - offx);
non_gui_paint_core.starty = non_gui_paint_core.lasty = (stroke_segs[0].y1 - offy);
seg = 0;
for (i = 0; i < num_strokes; i++)
{
while (stroke_segs[seg].x2 != -1)
{
non_gui_paint_core.curx = (stroke_segs[seg].x2 - offx - 0.125);
non_gui_paint_core.cury = (stroke_segs[seg].y2 - offy - 0.125);
non_gui_paint_core.curx = (stroke_segs[seg].x2 - offx);
non_gui_paint_core.cury = (stroke_segs[seg].y2 - offy);
paint_core_interpolate (&non_gui_paint_core, drawable);

View File

@ -438,8 +438,8 @@ void hls_to_rgb (int *, int *, int *);
#define SATURATION_MODE 12
#define COLOR_MODE 13
#define VALUE_MODE 14
#define ERASE_MODE 20
#define REPLACE_MODE 21
#define ERASE_MODE 15
#define REPLACE_MODE 16
/* Applying layer modes... */

View File

@ -68,10 +68,7 @@ static TempBuf * canvas_buf = NULL;
/* brush buffers */
static MaskBuf * solid_brush;
static MaskBuf * kernel_brushes[4][4] = { {NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL}};
static MaskBuf * kernel_brushes[5][5];
/* paint buffers utility functions */
@ -85,32 +82,42 @@ static void free_paint_buffers (void);
#define KERNEL_HEIGHT 3
/* Brush pixel subsampling kernels */
static int subsample[4][4][9] =
{
{
{ 16, 48, 0, 48, 144, 0, 0, 0, 0 },
{ 0, 64, 0, 0, 192, 0, 0, 0, 0 },
{ 0, 48, 16, 0, 144, 48, 0, 0, 0 },
{ 0, 32, 32, 0, 96, 96, 0, 0, 0 },
},
{
{ 0, 0, 0, 64, 192, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 256, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 192, 64, 0, 0, 0 },
{ 0, 0, 0, 0, 128, 128, 0, 0, 0 },
},
{
{ 0, 0, 0, 48, 144, 0, 16, 48, 0 },
{ 0, 0, 0, 0, 192, 0, 0, 64, 0 },
{ 0, 0, 0, 0, 144, 48, 0, 48, 16 },
{ 0, 0, 0, 0, 96, 96, 0, 32, 32 },
},
{
{ 0, 0, 0, 32, 96, 0, 32, 96, 0 },
{ 0, 0, 0, 0, 128, 0, 0, 128, 0 },
{ 0, 0, 0, 0, 96, 32, 0, 96, 32 },
{ 0, 0, 0, 0, 64, 64, 0, 64, 64 },
},
static int subsample[5][5][9] = {
{
{ 64, 64, 0, 64, 64, 0, 0, 0, 0, },
{ 32, 96, 0, 32, 96, 0, 0, 0, 0, },
{ 0, 128, 0, 0, 128, 0, 0, 0, 0, },
{ 0, 96, 32, 0, 96, 32, 0, 0, 0, },
{ 0, 64, 64, 0, 64, 64, 0, 0, 0, },
},
{
{ 32, 32, 0, 96, 96, 0, 0, 0, 0, },
{ 16, 48, 0, 48, 144, 0, 0, 0, 0, },
{ 0, 64, 0, 0, 192, 0, 0, 0, 0, },
{ 0, 48, 16, 0, 144, 48, 0, 0, 0, },
{ 0, 32, 32, 0, 96, 96, 0, 0, 0, },
},
{
{ 0, 0, 0, 128, 128, 0, 0, 0, 0, },
{ 0, 0, 0, 64, 192, 0, 0, 0, 0, },
{ 0, 0, 0, 0, 256, 0, 0, 0, 0, },
{ 0, 0, 0, 0, 192, 64, 0, 0, 0, },
{ 0, 0, 0, 0, 128, 128, 0, 0, 0, },
},
{
{ 0, 0, 0, 96, 96, 0, 32, 32, 0, },
{ 0, 0, 0, 48, 144, 0, 16, 48, 0, },
{ 0, 0, 0, 0, 192, 0, 0, 64, 0, },
{ 0, 0, 0, 0, 144, 48, 0, 48, 16, },
{ 0, 0, 0, 0, 96, 96, 0, 32, 32, },
},
{
{ 0, 0, 0, 64, 64, 0, 64, 64, 0, },
{ 0, 0, 0, 32, 96, 0, 32, 96, 0, },
{ 0, 0, 0, 0, 128, 0, 0, 128, 0, },
{ 0, 0, 0, 0, 96, 32, 0, 96, 32, },
{ 0, 0, 0, 0, 64, 64, 0, 64, 64, },
},
};
void
@ -687,22 +694,20 @@ paint_core_subsample_mask (mask, x, y)
int r, s;
x += (x < 0) ? mask->width : 0;
left = x - ((int) x);
left = x - floor(x) + 0.125;
index1 = (int) (left * 4);
index1 = (index1 < 0) ? 0 : index1;
y += (y < 0) ? mask->height : 0;
left = y - ((int) y);
left = y - floor(y) + 0.125;
index2 = (int) (left * 4);
index2 = (index2 < 0) ? 0 : index2;
kernel = subsample[index2][index1];
if ((mask == last_brush) && kernel_brushes[index2][index1])
return kernel_brushes[index2][index1];
else if (mask != last_brush)
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
{
if (kernel_brushes[i][j])
mask_buf_free (kernel_brushes[i][j]);

View File

@ -438,8 +438,8 @@ void hls_to_rgb (int *, int *, int *);
#define SATURATION_MODE 12
#define COLOR_MODE 13
#define VALUE_MODE 14
#define ERASE_MODE 20
#define REPLACE_MODE 21
#define ERASE_MODE 15
#define REPLACE_MODE 16
/* Applying layer modes... */

View File

@ -68,10 +68,7 @@ static TempBuf * canvas_buf = NULL;
/* brush buffers */
static MaskBuf * solid_brush;
static MaskBuf * kernel_brushes[4][4] = { {NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, NULL}};
static MaskBuf * kernel_brushes[5][5];
/* paint buffers utility functions */
@ -85,32 +82,42 @@ static void free_paint_buffers (void);
#define KERNEL_HEIGHT 3
/* Brush pixel subsampling kernels */
static int subsample[4][4][9] =
{
{
{ 16, 48, 0, 48, 144, 0, 0, 0, 0 },
{ 0, 64, 0, 0, 192, 0, 0, 0, 0 },
{ 0, 48, 16, 0, 144, 48, 0, 0, 0 },
{ 0, 32, 32, 0, 96, 96, 0, 0, 0 },
},
{
{ 0, 0, 0, 64, 192, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 256, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 192, 64, 0, 0, 0 },
{ 0, 0, 0, 0, 128, 128, 0, 0, 0 },
},
{
{ 0, 0, 0, 48, 144, 0, 16, 48, 0 },
{ 0, 0, 0, 0, 192, 0, 0, 64, 0 },
{ 0, 0, 0, 0, 144, 48, 0, 48, 16 },
{ 0, 0, 0, 0, 96, 96, 0, 32, 32 },
},
{
{ 0, 0, 0, 32, 96, 0, 32, 96, 0 },
{ 0, 0, 0, 0, 128, 0, 0, 128, 0 },
{ 0, 0, 0, 0, 96, 32, 0, 96, 32 },
{ 0, 0, 0, 0, 64, 64, 0, 64, 64 },
},
static int subsample[5][5][9] = {
{
{ 64, 64, 0, 64, 64, 0, 0, 0, 0, },
{ 32, 96, 0, 32, 96, 0, 0, 0, 0, },
{ 0, 128, 0, 0, 128, 0, 0, 0, 0, },
{ 0, 96, 32, 0, 96, 32, 0, 0, 0, },
{ 0, 64, 64, 0, 64, 64, 0, 0, 0, },
},
{
{ 32, 32, 0, 96, 96, 0, 0, 0, 0, },
{ 16, 48, 0, 48, 144, 0, 0, 0, 0, },
{ 0, 64, 0, 0, 192, 0, 0, 0, 0, },
{ 0, 48, 16, 0, 144, 48, 0, 0, 0, },
{ 0, 32, 32, 0, 96, 96, 0, 0, 0, },
},
{
{ 0, 0, 0, 128, 128, 0, 0, 0, 0, },
{ 0, 0, 0, 64, 192, 0, 0, 0, 0, },
{ 0, 0, 0, 0, 256, 0, 0, 0, 0, },
{ 0, 0, 0, 0, 192, 64, 0, 0, 0, },
{ 0, 0, 0, 0, 128, 128, 0, 0, 0, },
},
{
{ 0, 0, 0, 96, 96, 0, 32, 32, 0, },
{ 0, 0, 0, 48, 144, 0, 16, 48, 0, },
{ 0, 0, 0, 0, 192, 0, 0, 64, 0, },
{ 0, 0, 0, 0, 144, 48, 0, 48, 16, },
{ 0, 0, 0, 0, 96, 96, 0, 32, 32, },
},
{
{ 0, 0, 0, 64, 64, 0, 64, 64, 0, },
{ 0, 0, 0, 32, 96, 0, 32, 96, 0, },
{ 0, 0, 0, 0, 128, 0, 0, 128, 0, },
{ 0, 0, 0, 0, 96, 32, 0, 96, 32, },
{ 0, 0, 0, 0, 64, 64, 0, 64, 64, },
},
};
void
@ -687,22 +694,20 @@ paint_core_subsample_mask (mask, x, y)
int r, s;
x += (x < 0) ? mask->width : 0;
left = x - ((int) x);
left = x - floor(x) + 0.125;
index1 = (int) (left * 4);
index1 = (index1 < 0) ? 0 : index1;
y += (y < 0) ? mask->height : 0;
left = y - ((int) y);
left = y - floor(y) + 0.125;
index2 = (int) (left * 4);
index2 = (index2 < 0) ? 0 : index2;
kernel = subsample[index2][index1];
if ((mask == last_brush) && kernel_brushes[index2][index1])
return kernel_brushes[index2][index1];
else if (mask != last_brush)
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
{
if (kernel_brushes[i][j])
mask_buf_free (kernel_brushes[i][j]);