app/gimpbrushpip.[ch] app/airbrush.c app/pencil.c fix pencil tool for use

Wed Sep  1 00:56:37 EDT 1999 Adrian Likins <adrian@gimp.org>

        * app/gimpbrushpip.[ch]
        * app/airbrush.c
        * app/pencil.c
        * app/paintbrush.c: fix pencil tool for use with
           pixmaps again
This commit is contained in:
EDT 1999 Adrian Likins
1999-09-01 06:02:08 +00:00
committed by Adrian Likins
parent 6a71208875
commit 5e64804c4b
16 changed files with 166 additions and 75 deletions

View File

@ -1,3 +1,11 @@
Wed Sep 1 00:56:37 EDT 1999 Adrian Likins <adrian@gimp.org>
* app/gimpbrushpip.[ch]
* app/airbrush.c
* app/pencil.c
* app/paintbrush.c: fix pencil tool for use with
pixmaps again
1999-09-01 Tor Lillqvist <tml@iki.fi> 1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/tile_swap.c (tile_swap_open): Use _O_TEMPORARY. Removed * app/tile_swap.c (tile_swap_open): Use _O_TEMPORARY. Removed

View File

@ -297,8 +297,8 @@ airbrush_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL; mode = INCREMENTAL;
color_area_with_pixmap (paint_core, gimage, drawable, area, SOFT);
} }
else else
{ {

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "apptypes.h"
#include "appenv.h" #include "appenv.h"
#include "brush_header.h" #include "brush_header.h"
#include "pattern_header.h" #include "pattern_header.h"
@ -69,7 +70,8 @@ static void paint_line_pixmap_mask(GImage *dest,
int x, int x,
int y, int y,
int bytes, int bytes,
int width); int width,
int mode);
static void static void
gimp_brush_pixmap_destroy (GtkObject *object) gimp_brush_pixmap_destroy (GtkObject *object)
@ -585,7 +587,8 @@ void
color_area_with_pixmap (PaintCore *paint_core, color_area_with_pixmap (PaintCore *paint_core,
GImage *dest, GImage *dest,
GimpDrawable *drawable, GimpDrawable *drawable,
TempBuf *area) TempBuf *area,
int mode)
{ {
PixelRegion destPR; PixelRegion destPR;
@ -624,7 +627,7 @@ color_area_with_pixmap (PaintCore *paint_core,
{ {
paint_line_pixmap_mask (dest, drawable, pixmap, paint_line_pixmap_mask (dest, drawable, pixmap,
d, offsetx, y + offsety, d, offsetx, y + offsety,
destPR.bytes, destPR.w); destPR.bytes, destPR.w, mode);
d += destPR.rowstride; d += destPR.rowstride;
} }
} }
@ -638,7 +641,8 @@ paint_line_pixmap_mask (GImage *dest,
int x, int x,
int y, int y,
int bytes, int bytes,
int width) int width,
int mode)
{ {
guchar *b, *p; guchar *b, *p;
int x_index; int x_index;
@ -661,24 +665,45 @@ paint_line_pixmap_mask (GImage *dest,
/* ditto, except for the brush mask, so we can pre-multiply the alpha value */ /* ditto, except for the brush mask, so we can pre-multiply the alpha value */
mask = temp_buf_data((brush->gbrush).mask) + mask = temp_buf_data((brush->gbrush).mask) +
(y % brush->pixmap_mask->height) * brush->pixmap_mask->width; (y % brush->pixmap_mask->height) * brush->pixmap_mask->width;
for (i = 0; i < width; i++)
{
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % brush->pixmap_mask->width);
p = b + x_index * brush->pixmap_mask->bytes;
d[bytes-1] = mask[x_index];
/* multiply alpha into the pixmap data */ if(mode == SOFT)
/* maybe we could do this at tool creation or brush switch time? */ {
/* and compute it for the whole brush at once and cache it? */ for (i = 0; i < width; i++)
alpha = d[bytes-1] * factor; {
d[0] *= alpha; /* attempt to avoid doing this calc twice in the loop */
d[1] *= alpha; x_index = ((i + x) % brush->pixmap_mask->width);
d[2] *= alpha; p = b + x_index * brush->pixmap_mask->bytes;
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */ d[bytes-1] = mask[x_index];
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes; /* multiply alpha into the pixmap data */
/* maybe we could do this at tool creation or brush switch time? */
/* and compute it for the whole brush at once and cache it? */
if(alpha = d[bytes-1] * factor)
{
d[0] *= alpha;
d[1] *= alpha;
d[2] *= alpha;
}
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes;
}
}
else
{
for (i = 0; i < width; i++)
{
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % brush->pixmap_mask->width);
p = b + x_index * brush->pixmap_mask->bytes;
d[bytes-1] = 255;
/* multiply alpha into the pixmap data */
/* maybe we could do this at tool creation or brush switch time? */
/* and compute it for the whole brush at once and cache it? */
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes;
}
} }
} }

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "apptypes.h"
#include "appenv.h" #include "appenv.h"
#include "brush_header.h" #include "brush_header.h"
#include "pattern_header.h" #include "pattern_header.h"
@ -69,7 +70,8 @@ static void paint_line_pixmap_mask(GImage *dest,
int x, int x,
int y, int y,
int bytes, int bytes,
int width); int width,
int mode);
static void static void
gimp_brush_pixmap_destroy (GtkObject *object) gimp_brush_pixmap_destroy (GtkObject *object)
@ -585,7 +587,8 @@ void
color_area_with_pixmap (PaintCore *paint_core, color_area_with_pixmap (PaintCore *paint_core,
GImage *dest, GImage *dest,
GimpDrawable *drawable, GimpDrawable *drawable,
TempBuf *area) TempBuf *area,
int mode)
{ {
PixelRegion destPR; PixelRegion destPR;
@ -624,7 +627,7 @@ color_area_with_pixmap (PaintCore *paint_core,
{ {
paint_line_pixmap_mask (dest, drawable, pixmap, paint_line_pixmap_mask (dest, drawable, pixmap,
d, offsetx, y + offsety, d, offsetx, y + offsety,
destPR.bytes, destPR.w); destPR.bytes, destPR.w, mode);
d += destPR.rowstride; d += destPR.rowstride;
} }
} }
@ -638,7 +641,8 @@ paint_line_pixmap_mask (GImage *dest,
int x, int x,
int y, int y,
int bytes, int bytes,
int width) int width,
int mode)
{ {
guchar *b, *p; guchar *b, *p;
int x_index; int x_index;
@ -661,24 +665,45 @@ paint_line_pixmap_mask (GImage *dest,
/* ditto, except for the brush mask, so we can pre-multiply the alpha value */ /* ditto, except for the brush mask, so we can pre-multiply the alpha value */
mask = temp_buf_data((brush->gbrush).mask) + mask = temp_buf_data((brush->gbrush).mask) +
(y % brush->pixmap_mask->height) * brush->pixmap_mask->width; (y % brush->pixmap_mask->height) * brush->pixmap_mask->width;
for (i = 0; i < width; i++)
{
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % brush->pixmap_mask->width);
p = b + x_index * brush->pixmap_mask->bytes;
d[bytes-1] = mask[x_index];
/* multiply alpha into the pixmap data */ if(mode == SOFT)
/* maybe we could do this at tool creation or brush switch time? */ {
/* and compute it for the whole brush at once and cache it? */ for (i = 0; i < width; i++)
alpha = d[bytes-1] * factor; {
d[0] *= alpha; /* attempt to avoid doing this calc twice in the loop */
d[1] *= alpha; x_index = ((i + x) % brush->pixmap_mask->width);
d[2] *= alpha; p = b + x_index * brush->pixmap_mask->bytes;
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */ d[bytes-1] = mask[x_index];
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes; /* multiply alpha into the pixmap data */
/* maybe we could do this at tool creation or brush switch time? */
/* and compute it for the whole brush at once and cache it? */
if(alpha = d[bytes-1] * factor)
{
d[0] *= alpha;
d[1] *= alpha;
d[2] *= alpha;
}
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes;
}
}
else
{
for (i = 0; i < width; i++)
{
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % brush->pixmap_mask->width);
p = b + x_index * brush->pixmap_mask->bytes;
d[bytes-1] = 255;
/* multiply alpha into the pixmap data */
/* maybe we could do this at tool creation or brush switch time? */
/* and compute it for the whole brush at once and cache it? */
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes;
}
} }
} }

View File

@ -47,6 +47,7 @@ TempBuf *gimp_brush_pixmap_pixmap (GimpBrushPixmap *);
void color_area_with_pixmap (PaintCore *paint_core, void color_area_with_pixmap (PaintCore *paint_core,
GImage *dest, GImage *dest,
GimpDrawable *drawable, GimpDrawable *drawable,
TempBuf *area); TempBuf *area,
int mode);
#endif /* __GIMPBRUSHPIPE_H__ */ #endif /* __GIMPBRUSHPIPE_H__ */

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "apptypes.h"
#include "appenv.h" #include "appenv.h"
#include "brush_header.h" #include "brush_header.h"
#include "pattern_header.h" #include "pattern_header.h"
@ -69,7 +70,8 @@ static void paint_line_pixmap_mask(GImage *dest,
int x, int x,
int y, int y,
int bytes, int bytes,
int width); int width,
int mode);
static void static void
gimp_brush_pixmap_destroy (GtkObject *object) gimp_brush_pixmap_destroy (GtkObject *object)
@ -585,7 +587,8 @@ void
color_area_with_pixmap (PaintCore *paint_core, color_area_with_pixmap (PaintCore *paint_core,
GImage *dest, GImage *dest,
GimpDrawable *drawable, GimpDrawable *drawable,
TempBuf *area) TempBuf *area,
int mode)
{ {
PixelRegion destPR; PixelRegion destPR;
@ -624,7 +627,7 @@ color_area_with_pixmap (PaintCore *paint_core,
{ {
paint_line_pixmap_mask (dest, drawable, pixmap, paint_line_pixmap_mask (dest, drawable, pixmap,
d, offsetx, y + offsety, d, offsetx, y + offsety,
destPR.bytes, destPR.w); destPR.bytes, destPR.w, mode);
d += destPR.rowstride; d += destPR.rowstride;
} }
} }
@ -638,7 +641,8 @@ paint_line_pixmap_mask (GImage *dest,
int x, int x,
int y, int y,
int bytes, int bytes,
int width) int width,
int mode)
{ {
guchar *b, *p; guchar *b, *p;
int x_index; int x_index;
@ -661,24 +665,45 @@ paint_line_pixmap_mask (GImage *dest,
/* ditto, except for the brush mask, so we can pre-multiply the alpha value */ /* ditto, except for the brush mask, so we can pre-multiply the alpha value */
mask = temp_buf_data((brush->gbrush).mask) + mask = temp_buf_data((brush->gbrush).mask) +
(y % brush->pixmap_mask->height) * brush->pixmap_mask->width; (y % brush->pixmap_mask->height) * brush->pixmap_mask->width;
for (i = 0; i < width; i++)
{
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % brush->pixmap_mask->width);
p = b + x_index * brush->pixmap_mask->bytes;
d[bytes-1] = mask[x_index];
/* multiply alpha into the pixmap data */ if(mode == SOFT)
/* maybe we could do this at tool creation or brush switch time? */ {
/* and compute it for the whole brush at once and cache it? */ for (i = 0; i < width; i++)
alpha = d[bytes-1] * factor; {
d[0] *= alpha; /* attempt to avoid doing this calc twice in the loop */
d[1] *= alpha; x_index = ((i + x) % brush->pixmap_mask->width);
d[2] *= alpha; p = b + x_index * brush->pixmap_mask->bytes;
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */ d[bytes-1] = mask[x_index];
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes; /* multiply alpha into the pixmap data */
/* maybe we could do this at tool creation or brush switch time? */
/* and compute it for the whole brush at once and cache it? */
if(alpha = d[bytes-1] * factor)
{
d[0] *= alpha;
d[1] *= alpha;
d[2] *= alpha;
}
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes;
}
}
else
{
for (i = 0; i < width; i++)
{
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % brush->pixmap_mask->width);
p = b + x_index * brush->pixmap_mask->bytes;
d[bytes-1] = 255;
/* multiply alpha into the pixmap data */
/* maybe we could do this at tool creation or brush switch time? */
/* and compute it for the whole brush at once and cache it? */
gimage_transform_color (dest, drawable, p, d, RGB);
d += bytes;
}
} }
} }

View File

@ -47,6 +47,7 @@ TempBuf *gimp_brush_pixmap_pixmap (GimpBrushPixmap *);
void color_area_with_pixmap (PaintCore *paint_core, void color_area_with_pixmap (PaintCore *paint_core,
GImage *dest, GImage *dest,
GimpDrawable *drawable, GimpDrawable *drawable,
TempBuf *area); TempBuf *area,
int mode);
#endif /* __GIMPBRUSHPIPE_H__ */ #endif /* __GIMPBRUSHPIPE_H__ */

View File

@ -297,8 +297,8 @@ airbrush_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL; mode = INCREMENTAL;
color_area_with_pixmap (paint_core, gimage, drawable, area, SOFT);
} }
else else
{ {

View File

@ -182,7 +182,8 @@ pencil_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
/* if its a pixmap, do pixmap stuff */ /* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (paint_core, gimage, drawable, area);
color_area_with_pixmap (paint_core, gimage, drawable, area,HARD );
paint_appl_mode = INCREMENTAL; paint_appl_mode = INCREMENTAL;
} }
else else

View File

@ -352,6 +352,7 @@ tools_new_paintbrush ()
private->pick_colors = TRUE; private->pick_colors = TRUE;
private->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; private->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
return tool; return tool;
} }
@ -441,7 +442,7 @@ paintbrush_motion (PaintCore *paint_core,
pixmap image into the are instead of the color */ pixmap image into the are instead of the color */
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length)
{ {
color_area_with_pixmap (paint_core, gimage, drawable, area); color_area_with_pixmap (paint_core, gimage, drawable, area, SOFT);
paint_appl_mode = INCREMENTAL; paint_appl_mode = INCREMENTAL;
} }
else else

View File

@ -182,7 +182,8 @@ pencil_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
/* if its a pixmap, do pixmap stuff */ /* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (paint_core, gimage, drawable, area);
color_area_with_pixmap (paint_core, gimage, drawable, area,HARD );
paint_appl_mode = INCREMENTAL; paint_appl_mode = INCREMENTAL;
} }
else else

View File

@ -297,8 +297,8 @@ airbrush_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL; mode = INCREMENTAL;
color_area_with_pixmap (paint_core, gimage, drawable, area, SOFT);
} }
else else
{ {

View File

@ -297,8 +297,8 @@ airbrush_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL; mode = INCREMENTAL;
color_area_with_pixmap (paint_core, gimage, drawable, area, SOFT);
} }
else else
{ {

View File

@ -182,7 +182,8 @@ pencil_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
/* if its a pixmap, do pixmap stuff */ /* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (paint_core, gimage, drawable, area);
color_area_with_pixmap (paint_core, gimage, drawable, area,HARD );
paint_appl_mode = INCREMENTAL; paint_appl_mode = INCREMENTAL;
} }
else else

View File

@ -352,6 +352,7 @@ tools_new_paintbrush ()
private->pick_colors = TRUE; private->pick_colors = TRUE;
private->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH; private->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
return tool; return tool;
} }
@ -441,7 +442,7 @@ paintbrush_motion (PaintCore *paint_core,
pixmap image into the are instead of the color */ pixmap image into the are instead of the color */
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length)
{ {
color_area_with_pixmap (paint_core, gimage, drawable, area); color_area_with_pixmap (paint_core, gimage, drawable, area, SOFT);
paint_appl_mode = INCREMENTAL; paint_appl_mode = INCREMENTAL;
} }
else else

View File

@ -182,7 +182,8 @@ pencil_motion (PaintCore *paint_core,
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush)) if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{ {
/* if its a pixmap, do pixmap stuff */ /* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (paint_core, gimage, drawable, area);
color_area_with_pixmap (paint_core, gimage, drawable, area,HARD );
paint_appl_mode = INCREMENTAL; paint_appl_mode = INCREMENTAL;
} }
else else