Overhaul of pixmap brushes and pipes: No separate pixmap pipe

brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.

* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.

* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.

* app/gimpbrushpipe.{h,c}: Total overhaul.

* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h

* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.

* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.

* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).

* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.

* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.

* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.

Other changes in the same commit:

* app/install.c: Make quote_spaces extern.

* app/appenv.h: Declare it.

* libgimp/gimpui.def: Add missing entry points.

* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
This commit is contained in:
Tor Lillqvist 1999-08-26 00:54:30 +00:00
parent 3cf62e52d4
commit 868bdfff44
47 changed files with 1394 additions and 477 deletions

View file

@ -187,8 +187,6 @@ gimp_SOURCES = \
gimpbrushgenerated.h \
gimpbrushpipe.c \
gimpbrushpipe.h \
gimpbrushpixmap.c \
gimpbrushpixmap.h \
gimpbrushlist.c \
gimpbrushlist.h \
gimpbrushlistF.h \
@ -330,8 +328,6 @@ gimp_SOURCES = \
pixel_region.c \
pixel_region.h \
pixel_regionP.h \
pixmapbrush.c \
pixmapbrush.h \
pixmaps.h \
pixmaps2.h \
plug_in.c \

View file

@ -18,7 +18,7 @@
#include <stdlib.h>
#include "appenv.h"
#include "gimpbrushlist.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
@ -26,8 +26,6 @@
#include "paint_core.h"
#include "paint_options.h"
#include "palette.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "airbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
@ -293,23 +291,19 @@ airbrush_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* color the pixels */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -92,4 +92,8 @@ extern int we_are_exiting; /* this is used in session_get_window_info() */
extern GimpSet* image_context;
extern MessageHandlerType message_handler;
#ifdef NATIVE_WIN32
char *quote_spaces (char *string);
#endif
#endif /* APPENV_H */

View file

@ -135,19 +135,25 @@ typedef enum
NEAREST_NEIGHBOR_INTERPOLATION
} InterpolationType;
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpChannelClass GimpChannelClass;
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpChannelClass GimpChannelClass;
typedef GimpChannel Channel; /* convenience */
typedef struct _GimpLayer GimpLayer;
typedef struct _GimpLayerClass GimpLayerClass;
typedef struct _GimpLayer GimpLayer;
typedef struct _GimpLayerClass GimpLayerClass;
typedef struct _GimpLayerMask GimpLayerMask;
typedef struct _GimpLayerMaskClass GimpLayerMaskClass;
typedef GimpLayer Layer; /* convenience */
typedef GimpLayerMask LayerMask; /* convenience */
typedef struct _paint_core PaintCore;
typedef struct _GimpBrush GimpBrush;
typedef struct _GimpBrush *GimpBrushP;
typedef struct _GimpBrushClass GimpBrushClass;
typedef struct _layer_undo LayerUndo;
typedef struct _layer_mask_undo LayerMaskUndo;

View file

@ -20,7 +20,7 @@
#include "appenv.h"
#include "actionarea.h"
#include "brush_scale.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "gimpbrushlist.h"
#include "gimpcontext.h"
#include "gimplist.h"
@ -736,7 +736,7 @@ brush_popup_timeout (gpointer data)
if (GIMP_IS_BRUSH_PIXMAP (brush))
{
GimpBrushPixmap *pixmapbrush = GIMP_BRUSH_PIXMAP(brush);
src = (gchar *) temp_buf_data (pixmapbrush->pixmap_mask);
src = (gchar *) temp_buf_data (gimp_brush_pixmap_pixmap (pixmapbrush));
for (y = 0; y < brush->mask->height; y++)
{
gtk_preview_draw_row (GTK_PREVIEW (bsp->brush_preview), (guchar *)src,
@ -817,8 +817,9 @@ display_brush (BrushSelectP bsp,
int ystart;
int i, j;
brush_buf = GIMP_IS_BRUSH_PIXMAP (brush) ? GIMP_BRUSH_PIXMAP(brush)->pixmap_mask
: brush->mask;
brush_buf = GIMP_IS_BRUSH_PIXMAP (brush) ?
gimp_brush_pixmap_pixmap (GIMP_BRUSH_PIXMAP(brush))
: brush->mask;
if (brush_buf->width > bsp->cell_width || brush_buf->height > bsp->cell_height)
{

View file

@ -92,7 +92,6 @@ context_manager_init (void)
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
tool_info[i].tool_context =
gimp_context_new (tool_info[i].private_tip, NULL, context);
break;

View file

@ -33,6 +33,8 @@ enum{
LAST_SIGNAL
};
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
static guint gimp_brush_signals[LAST_SIGNAL];
static GimpObjectClass* parent_class;
@ -64,6 +66,8 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
klass->select_brush = gimp_brush_select_brush;
gimp_brush_signals[DIRTY] =
gimp_signal_new ("dirty", GTK_RUN_FIRST, type, 0, gimp_sigtype_void);
@ -116,6 +120,12 @@ gimp_brush_new (char *filename)
return brush;
}
static GimpBrush *
gimp_brush_select_brush (PaintCore *paint_core)
{
return paint_core->brush;
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{

View file

@ -33,6 +33,8 @@ enum{
LAST_SIGNAL
};
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
static guint gimp_brush_signals[LAST_SIGNAL];
static GimpObjectClass* parent_class;
@ -64,6 +66,8 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
klass->select_brush = gimp_brush_select_brush;
gimp_brush_signals[DIRTY] =
gimp_signal_new ("dirty", GTK_RUN_FIRST, type, 0, gimp_sigtype_void);
@ -116,6 +120,12 @@ gimp_brush_new (char *filename)
return brush;
}
static GimpBrush *
gimp_brush_select_brush (PaintCore *paint_core)
{
return paint_core->brush;
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{

View file

@ -20,12 +20,13 @@
#define __GIMPBRUSH_H__
#include <stdio.h>
#include "apptypes.h"
#include "gimpobjectP.h"
#include "paint_core.h"
#include "temp_buf.h"
#include "vector2d.h"
typedef struct _GimpBrush GimpBrush, * GimpBrushP;
struct _GimpBrush
{
GimpObject gobject;
@ -40,10 +41,10 @@ struct _GimpBrush
struct _GimpBrushClass
{
GimpObjectClass parent_class;
GimpBrush *(* select_brush) (PaintCore *);
};
typedef struct _GimpBrushClass GimpBrushClass;
#define BRUSH_CLASS(klass) \
#define GIMP_BRUSH_CLASS(klass) \
GTK_CHECK_CLASS_CAST (klass, gimp_brush_get_type(), GimpBrushClass)
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())

View file

@ -1,33 +1,152 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "appenv.h"
#include "brush_header.h"
#include "pattern_header.h"
#include "patterns.h"
#include "gimpbrush.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushlist.h"
#include "gimpbrushpipe.h"
#include "gimpbrushpipeP.h"
#include "paint_core.h"
#include "gimprc.h"
#include "gimpbrushpipe.h"
#include "libgimp/gimpintl.h"
static void
gimp_brush_pipe_generate(GimpBrushPipe *brush);
static GimpBrushClass* gimp_brush_class;
static GtkObjectClass* gimp_object_class;
static GimpObjectClass* parent_class;
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
static void paint_line_pixmap_mask(GImage *dest,
GimpDrawable *drawable,
GimpBrushPixmap *brush,
guchar *d,
int x,
int y,
int bytes,
int width);
static void
gimp_brush_pixmap_destroy (GtkObject *object)
{
GimpBrushPixmap *pixmap;
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
pixmap = GIMP_BRUSH_PIXMAP (object);
temp_buf_free (pixmap->pixmap_mask);
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
}
static void
gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
{
GtkObjectClass *object_class;
GimpBrushClass *brush_class;
object_class = GTK_OBJECT_CLASS (klass);
brush_class = GIMP_BRUSH_CLASS (klass);
gimp_brush_class = gtk_type_class (gimp_brush_get_type ());
object_class->destroy = gimp_brush_pixmap_destroy;
brush_class->select_brush = gimp_brush_pixmap_select_brush;
}
void
gimp_brush_pixmap_init (GimpBrushPixmap *brush)
{
brush->pixmap_mask = NULL;
brush->pipe = NULL;
}
GtkType
gimp_brush_pixmap_get_type (void)
{
static GtkType type=0;
if(!type){
GtkTypeInfo info={
"GimpBrushPixmap",
sizeof (GimpBrushPixmap),
sizeof (GimpBrushPixmapClass),
(GtkClassInitFunc) gimp_brush_pixmap_class_init,
(GtkObjectInitFunc) gimp_brush_pixmap_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL};
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
}
return type;
}
static GimpBrush *
gimp_brush_pixmap_select_brush (PaintCore *paint_core)
{
GimpBrushPixmap *pixmap;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), NULL);
pixmap = GIMP_BRUSH_PIXMAP (paint_core->brush);
if (pixmap->pipe->nbrushes == 1)
return GIMP_BRUSH (pixmap->pipe->current);
/* Just select the next one for now. This is the place where we
* will select the correct brush based on various parameters
* in paint_core.
*/
pixmap->pipe->index[0] = (pixmap->pipe->index[0] + 1) % pixmap->pipe->nbrushes;
pixmap->pipe->current = pixmap->pipe->brushes[pixmap->pipe->index[0]];
return GIMP_BRUSH (pixmap->pipe->current);
}
static void
gimp_brush_pipe_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
GimpBrushPipe *pipe;
int i;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_BRUSH_PIPE (object));
pipe = GIMP_BRUSH_PIPE (object);
g_free (pipe->rank);
for (i = 1; i < pipe->nbrushes; i++)
gimp_object_destroy (pipe->brushes[i]);
g_free (pipe->brushes);
g_free (pipe->select);
g_free (pipe->index);
if (GTK_OBJECT_CLASS (gimp_object_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
}
static void
@ -35,116 +154,294 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS(klass);
parent_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP);
object_class->destroy = gimp_brush_pipe_destroy;
object_class = GTK_OBJECT_CLASS (klass);
gimp_object_class = gtk_type_class (GIMP_TYPE_OBJECT);
object_class->destroy = gimp_brush_pipe_destroy;
}
void
gimp_brush_pipe_init(GimpBrushPipe *brush)
gimp_brush_pipe_init (GimpBrushPipe *pipe)
{
brush->name = NULL;
brush->filename = NULL;
brush->brush_list = gimp_brush_list_new();
pipe->dimension = 0;
pipe->rank = NULL;
pipe->nbrushes = 0;
pipe->select = NULL;
pipe->index = NULL;
}
GtkType gimp_brush_pipe_get_type(void)
GtkType
gimp_brush_pipe_get_type (void)
{
static GtkType type=0;
if(!type){
if (!type){
GtkTypeInfo info={
"GimpBrushPipe",
sizeof(GimpBrushPipe),
sizeof(GimpBrushPipeClass),
(GtkClassInitFunc)gimp_brush_pipe_class_init,
(GtkObjectInitFunc)gimp_brush_pipe_init,
/* reserved_1 */ NULL,
/* reserver_2 */ NULL,
sizeof (GimpBrushPipe),
sizeof (GimpBrushPipeClass),
(GtkClassInitFunc) gimp_brush_pipe_class_init,
(GtkObjectInitFunc) gimp_brush_pipe_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL};
type=gtk_type_unique(GIMP_TYPE_BRUSH_PIXMAP, &info);
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
}
return type;
}
GimpBrushPipe *
gimp_brush_pipe_load (char *file_name)
gimp_brush_pipe_load (char *filename)
{
GimpBrushPipe *pipe;
GimpBrushPixmap *brush;
GimpBrushList *list;
GPatternP pattern;
FILE *fp;
gchar buf2[1024];
guchar buf[1024];
guchar *name;
int num_of_brushes;
int brush_count=0;
guchar *params;
pipe = GIMP_BRUSH_PIPE(gimp_type_new(gimp_brush_pipe_get_type()));
GIMP_BRUSH_PIPE(pipe)->filename = g_strdup(file_name);
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
/* The file format starts with a painfully simple text header
* and we use a painfully simple way to read it
*/
if (fgets (buf, 1024, fp) == NULL)
{
fclose (fp);
return NULL;
}
buf[strlen (buf) - 1] = 0;
pipe = GIMP_BRUSH_PIPE (gimp_type_new (GIMP_TYPE_BRUSH_PIPE));
name = g_strdup (buf);
/* get the number of brushes */
if (fgets (buf, 1024, fp) == NULL)
{
fclose (fp);
gimp_object_destroy (pipe);
return NULL;
}
num_of_brushes = strtol(buf, &params, 10);
if (num_of_brushes < 1)
{
g_message (_("pixmap brush pipe should have at least one brush"));
fclose (fp);
gimp_object_destroy (pipe);
return NULL;
}
/* Here we should parse the params to get the dimension, ranks,
* placement options, etc. But just use defaults for now.
*/
pipe->dimension = 1;
pipe->rank = g_new (int, 1);
pipe->rank[0] = num_of_brushes;
pipe->select = g_new (PipeSelectModes, 1);
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
pipe->index = g_new (int, 1);
pipe->index[0] = 0;
pattern = (GPatternP) g_malloc (sizeof (GPattern));
pattern->filename = g_strdup (file_name);
pattern->filename = NULL;
pattern->name = NULL;
pattern->mask = NULL;
brush = GIMP_BRUSH_PIXMAP (pipe);
pipe->brushes =
(GimpBrushPixmap **) g_new0 (GimpBrushPixmap *, num_of_brushes);
list = gimp_brush_list_new();
/* First pixmap brush in the list is the pipe itself */
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
if ((fp = fopen(file_name, "rb")) == NULL)
return NULL;
/* the file format starts with a painfully simple text header
and we use a painfully simple way to read it */
if(fgets (buf2, 1024, fp) == NULL)
return NULL;
buf2[strlen(buf2) - 1] = '\0';
pipe->name = g_strdup(buf2);
/* Current pixmap brush is the first one. */
pipe->current = pipe->brushes[0];
/* get the number of brushes */
if(fgets (buf2, 1024, fp) == NULL)
return NULL;
num_of_brushes = strtol(buf2,NULL,10);
while(brush_count < num_of_brushes)
while (pipe->nbrushes < num_of_brushes)
{
if (brush_count > 0)
brush = GIMP_BRUSH_PIXMAP(gimp_type_new(gimp_brush_pixmap_get_type()));
GIMP_BRUSH(brush)->filename = g_strdup(file_name);
if (pipe->nbrushes > 0)
{
pipe->brushes[pipe->nbrushes] =
GIMP_BRUSH_PIXMAP (gimp_type_new (GIMP_TYPE_BRUSH_PIXMAP));
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
}
pipe->brushes[pipe->nbrushes]->pipe = pipe;
/* load the brush */
if(!gimp_brush_load_brush(GIMP_BRUSH(brush),fp,file_name))
{
g_message (_("failed to load a brush mask in the pipe"));
return NULL;
}
/* load the pattern data*/
if(!load_pattern_pattern(pattern, fp, file_name))
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[pipe->nbrushes]),
fp, filename)
|| !load_pattern_pattern (pattern, fp, filename))
{
g_message (_("failed to load a section of pixmap mask in the pipe"));
g_message (_("failed to load one of the pixmap brushes in the pipe"));
fclose (fp);
g_free (pattern);
gimp_object_destroy (pipe);
return NULL;
}
brush->pixmap_mask = pattern->mask;
gimp_brush_list_add(list,GIMP_BRUSH(brush));
brush_count++;
if (pipe->nbrushes == 0)
{
/* Replace name with the whole pipe's name */
GIMP_BRUSH (pipe)->name = name;
}
pipe->brushes[pipe->nbrushes]->pixmap_mask = pattern->mask;
pipe->nbrushes++;
}
/* Clean up */
fclose (fp);
if (!GIMP_IS_BRUSH_PIPE(pipe))
g_print ("Is not BRUSH_PIPE???\n");
pipe->brush_list = list;
g_free(pattern);
return pipe;
}
GimpBrushPipe *
gimp_brush_pixmap_load (char *filename)
{
GimpBrushPipe *pipe;
GPatternP pattern;
FILE *fp;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
pipe = GIMP_BRUSH_PIPE (gimp_type_new (GIMP_TYPE_BRUSH_PIPE));
/* A (single) pixmap brush is a pixmap pipe brush with just one pixmap */
pipe->dimension = 1;
pipe->rank = g_new (int, 1);
pipe->rank[0] = 1;
pipe->select = g_new (PipeSelectModes, 1);
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
pipe->index = g_new (int, 1);
pipe->index[0] = 0;
pattern = (GPatternP) g_malloc (sizeof (GPattern));
pattern->filename = NULL;
pattern->name = NULL;
pattern->mask = NULL;
pipe->brushes = (GimpBrushPixmap **) g_new (GimpBrushPixmap *, 1);
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
pipe->current = pipe->brushes[0];
pipe->brushes[0]->pipe = pipe;
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[0]),
fp, filename)
|| !load_pattern_pattern (pattern, fp, filename))
{
g_message (_("failed to load pixmap brush"));
fclose (fp);
g_free (pattern);
gimp_object_destroy (pipe);
return NULL;
}
pipe->brushes[0]->pixmap_mask = pattern->mask;
pipe->nbrushes = 1;
/* Clean up */
fclose (fp);
g_free(pattern);
return pipe;
}
TempBuf *
gimp_brush_pixmap_pixmap (GimpBrushPixmap *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (brush), NULL);
return brush->pixmap_mask;
}
void
color_area_with_pixmap (PaintCore *paint_core,
GImage *dest,
GimpDrawable *drawable,
TempBuf *area)
{
PixelRegion destPR;
void *pr;
guchar *d;
int ulx, uly, offsetx, offsety, y;
GimpBrushPixmap *pixmap;
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush));
pixmap = GIMP_BRUSH_PIXMAP (paint_core->brush);
destPR.bytes = area->bytes;
destPR.x = 0; destPR.y = 0;
destPR.w = area->width;
destPR.h = area->height;
destPR.rowstride = destPR.bytes * area->width;
destPR.data = temp_buf_data (area);
pr = pixel_regions_register (1, &destPR);
/* Calculate upper left corner of brush as in
* paint_core_get_paint_area. Ugly to have to do this here, too.
*/
ulx = (int) paint_core->curx - (paint_core->brush->mask->width >> 1);
uly = (int) paint_core->cury - (paint_core->brush->mask->height >> 1);
offsetx = area->x - ulx;
offsety = area->y - uly;
for (; pr != NULL; pr = pixel_regions_process (pr))
{
d = destPR.data;
for (y = 0; y < destPR.h; y++)
{
paint_line_pixmap_mask (dest, drawable, pixmap,
d, offsetx, y + offsety,
destPR.bytes, destPR.w);
d += destPR.rowstride;
}
}
}
static void
paint_line_pixmap_mask (GImage *dest,
GimpDrawable *drawable,
GimpBrushPixmap *brush,
guchar *d,
int x,
int y,
int bytes,
int width)
{
guchar *b, *p;
int alpha;
int i;
/* Make sure x, y are positive */
while (x < 0)
x += brush->pixmap_mask->width;
while (y < 0)
y += brush->pixmap_mask->height;
/* Point to the approriate scanline */
b = temp_buf_data (brush->pixmap_mask) +
(y % brush->pixmap_mask->height) * brush->pixmap_mask->width * brush->pixmap_mask->bytes;
for (i = 0; i < width; i++)
{
p = b + ((i + x) % brush->pixmap_mask->width)
* brush->pixmap_mask->bytes;
d[bytes-1] = OPAQUE_OPACITY;
/* 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;
}
}

View file

@ -1,33 +1,152 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "appenv.h"
#include "brush_header.h"
#include "pattern_header.h"
#include "patterns.h"
#include "gimpbrush.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushlist.h"
#include "gimpbrushpipe.h"
#include "gimpbrushpipeP.h"
#include "paint_core.h"
#include "gimprc.h"
#include "gimpbrushpipe.h"
#include "libgimp/gimpintl.h"
static void
gimp_brush_pipe_generate(GimpBrushPipe *brush);
static GimpBrushClass* gimp_brush_class;
static GtkObjectClass* gimp_object_class;
static GimpObjectClass* parent_class;
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
static void paint_line_pixmap_mask(GImage *dest,
GimpDrawable *drawable,
GimpBrushPixmap *brush,
guchar *d,
int x,
int y,
int bytes,
int width);
static void
gimp_brush_pixmap_destroy (GtkObject *object)
{
GimpBrushPixmap *pixmap;
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
pixmap = GIMP_BRUSH_PIXMAP (object);
temp_buf_free (pixmap->pixmap_mask);
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
}
static void
gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
{
GtkObjectClass *object_class;
GimpBrushClass *brush_class;
object_class = GTK_OBJECT_CLASS (klass);
brush_class = GIMP_BRUSH_CLASS (klass);
gimp_brush_class = gtk_type_class (gimp_brush_get_type ());
object_class->destroy = gimp_brush_pixmap_destroy;
brush_class->select_brush = gimp_brush_pixmap_select_brush;
}
void
gimp_brush_pixmap_init (GimpBrushPixmap *brush)
{
brush->pixmap_mask = NULL;
brush->pipe = NULL;
}
GtkType
gimp_brush_pixmap_get_type (void)
{
static GtkType type=0;
if(!type){
GtkTypeInfo info={
"GimpBrushPixmap",
sizeof (GimpBrushPixmap),
sizeof (GimpBrushPixmapClass),
(GtkClassInitFunc) gimp_brush_pixmap_class_init,
(GtkObjectInitFunc) gimp_brush_pixmap_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL};
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
}
return type;
}
static GimpBrush *
gimp_brush_pixmap_select_brush (PaintCore *paint_core)
{
GimpBrushPixmap *pixmap;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), NULL);
pixmap = GIMP_BRUSH_PIXMAP (paint_core->brush);
if (pixmap->pipe->nbrushes == 1)
return GIMP_BRUSH (pixmap->pipe->current);
/* Just select the next one for now. This is the place where we
* will select the correct brush based on various parameters
* in paint_core.
*/
pixmap->pipe->index[0] = (pixmap->pipe->index[0] + 1) % pixmap->pipe->nbrushes;
pixmap->pipe->current = pixmap->pipe->brushes[pixmap->pipe->index[0]];
return GIMP_BRUSH (pixmap->pipe->current);
}
static void
gimp_brush_pipe_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
GimpBrushPipe *pipe;
int i;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_BRUSH_PIPE (object));
pipe = GIMP_BRUSH_PIPE (object);
g_free (pipe->rank);
for (i = 1; i < pipe->nbrushes; i++)
gimp_object_destroy (pipe->brushes[i]);
g_free (pipe->brushes);
g_free (pipe->select);
g_free (pipe->index);
if (GTK_OBJECT_CLASS (gimp_object_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
}
static void
@ -35,116 +154,294 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS(klass);
parent_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP);
object_class->destroy = gimp_brush_pipe_destroy;
object_class = GTK_OBJECT_CLASS (klass);
gimp_object_class = gtk_type_class (GIMP_TYPE_OBJECT);
object_class->destroy = gimp_brush_pipe_destroy;
}
void
gimp_brush_pipe_init(GimpBrushPipe *brush)
gimp_brush_pipe_init (GimpBrushPipe *pipe)
{
brush->name = NULL;
brush->filename = NULL;
brush->brush_list = gimp_brush_list_new();
pipe->dimension = 0;
pipe->rank = NULL;
pipe->nbrushes = 0;
pipe->select = NULL;
pipe->index = NULL;
}
GtkType gimp_brush_pipe_get_type(void)
GtkType
gimp_brush_pipe_get_type (void)
{
static GtkType type=0;
if(!type){
if (!type){
GtkTypeInfo info={
"GimpBrushPipe",
sizeof(GimpBrushPipe),
sizeof(GimpBrushPipeClass),
(GtkClassInitFunc)gimp_brush_pipe_class_init,
(GtkObjectInitFunc)gimp_brush_pipe_init,
/* reserved_1 */ NULL,
/* reserver_2 */ NULL,
sizeof (GimpBrushPipe),
sizeof (GimpBrushPipeClass),
(GtkClassInitFunc) gimp_brush_pipe_class_init,
(GtkObjectInitFunc) gimp_brush_pipe_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL};
type=gtk_type_unique(GIMP_TYPE_BRUSH_PIXMAP, &info);
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
}
return type;
}
GimpBrushPipe *
gimp_brush_pipe_load (char *file_name)
gimp_brush_pipe_load (char *filename)
{
GimpBrushPipe *pipe;
GimpBrushPixmap *brush;
GimpBrushList *list;
GPatternP pattern;
FILE *fp;
gchar buf2[1024];
guchar buf[1024];
guchar *name;
int num_of_brushes;
int brush_count=0;
guchar *params;
pipe = GIMP_BRUSH_PIPE(gimp_type_new(gimp_brush_pipe_get_type()));
GIMP_BRUSH_PIPE(pipe)->filename = g_strdup(file_name);
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
/* The file format starts with a painfully simple text header
* and we use a painfully simple way to read it
*/
if (fgets (buf, 1024, fp) == NULL)
{
fclose (fp);
return NULL;
}
buf[strlen (buf) - 1] = 0;
pipe = GIMP_BRUSH_PIPE (gimp_type_new (GIMP_TYPE_BRUSH_PIPE));
name = g_strdup (buf);
/* get the number of brushes */
if (fgets (buf, 1024, fp) == NULL)
{
fclose (fp);
gimp_object_destroy (pipe);
return NULL;
}
num_of_brushes = strtol(buf, &params, 10);
if (num_of_brushes < 1)
{
g_message (_("pixmap brush pipe should have at least one brush"));
fclose (fp);
gimp_object_destroy (pipe);
return NULL;
}
/* Here we should parse the params to get the dimension, ranks,
* placement options, etc. But just use defaults for now.
*/
pipe->dimension = 1;
pipe->rank = g_new (int, 1);
pipe->rank[0] = num_of_brushes;
pipe->select = g_new (PipeSelectModes, 1);
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
pipe->index = g_new (int, 1);
pipe->index[0] = 0;
pattern = (GPatternP) g_malloc (sizeof (GPattern));
pattern->filename = g_strdup (file_name);
pattern->filename = NULL;
pattern->name = NULL;
pattern->mask = NULL;
brush = GIMP_BRUSH_PIXMAP (pipe);
pipe->brushes =
(GimpBrushPixmap **) g_new0 (GimpBrushPixmap *, num_of_brushes);
list = gimp_brush_list_new();
/* First pixmap brush in the list is the pipe itself */
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
if ((fp = fopen(file_name, "rb")) == NULL)
return NULL;
/* the file format starts with a painfully simple text header
and we use a painfully simple way to read it */
if(fgets (buf2, 1024, fp) == NULL)
return NULL;
buf2[strlen(buf2) - 1] = '\0';
pipe->name = g_strdup(buf2);
/* Current pixmap brush is the first one. */
pipe->current = pipe->brushes[0];
/* get the number of brushes */
if(fgets (buf2, 1024, fp) == NULL)
return NULL;
num_of_brushes = strtol(buf2,NULL,10);
while(brush_count < num_of_brushes)
while (pipe->nbrushes < num_of_brushes)
{
if (brush_count > 0)
brush = GIMP_BRUSH_PIXMAP(gimp_type_new(gimp_brush_pixmap_get_type()));
GIMP_BRUSH(brush)->filename = g_strdup(file_name);
if (pipe->nbrushes > 0)
{
pipe->brushes[pipe->nbrushes] =
GIMP_BRUSH_PIXMAP (gimp_type_new (GIMP_TYPE_BRUSH_PIXMAP));
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
}
pipe->brushes[pipe->nbrushes]->pipe = pipe;
/* load the brush */
if(!gimp_brush_load_brush(GIMP_BRUSH(brush),fp,file_name))
{
g_message (_("failed to load a brush mask in the pipe"));
return NULL;
}
/* load the pattern data*/
if(!load_pattern_pattern(pattern, fp, file_name))
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[pipe->nbrushes]),
fp, filename)
|| !load_pattern_pattern (pattern, fp, filename))
{
g_message (_("failed to load a section of pixmap mask in the pipe"));
g_message (_("failed to load one of the pixmap brushes in the pipe"));
fclose (fp);
g_free (pattern);
gimp_object_destroy (pipe);
return NULL;
}
brush->pixmap_mask = pattern->mask;
gimp_brush_list_add(list,GIMP_BRUSH(brush));
brush_count++;
if (pipe->nbrushes == 0)
{
/* Replace name with the whole pipe's name */
GIMP_BRUSH (pipe)->name = name;
}
pipe->brushes[pipe->nbrushes]->pixmap_mask = pattern->mask;
pipe->nbrushes++;
}
/* Clean up */
fclose (fp);
if (!GIMP_IS_BRUSH_PIPE(pipe))
g_print ("Is not BRUSH_PIPE???\n");
pipe->brush_list = list;
g_free(pattern);
return pipe;
}
GimpBrushPipe *
gimp_brush_pixmap_load (char *filename)
{
GimpBrushPipe *pipe;
GPatternP pattern;
FILE *fp;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
pipe = GIMP_BRUSH_PIPE (gimp_type_new (GIMP_TYPE_BRUSH_PIPE));
/* A (single) pixmap brush is a pixmap pipe brush with just one pixmap */
pipe->dimension = 1;
pipe->rank = g_new (int, 1);
pipe->rank[0] = 1;
pipe->select = g_new (PipeSelectModes, 1);
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
pipe->index = g_new (int, 1);
pipe->index[0] = 0;
pattern = (GPatternP) g_malloc (sizeof (GPattern));
pattern->filename = NULL;
pattern->name = NULL;
pattern->mask = NULL;
pipe->brushes = (GimpBrushPixmap **) g_new (GimpBrushPixmap *, 1);
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
pipe->current = pipe->brushes[0];
pipe->brushes[0]->pipe = pipe;
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[0]),
fp, filename)
|| !load_pattern_pattern (pattern, fp, filename))
{
g_message (_("failed to load pixmap brush"));
fclose (fp);
g_free (pattern);
gimp_object_destroy (pipe);
return NULL;
}
pipe->brushes[0]->pixmap_mask = pattern->mask;
pipe->nbrushes = 1;
/* Clean up */
fclose (fp);
g_free(pattern);
return pipe;
}
TempBuf *
gimp_brush_pixmap_pixmap (GimpBrushPixmap *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (brush), NULL);
return brush->pixmap_mask;
}
void
color_area_with_pixmap (PaintCore *paint_core,
GImage *dest,
GimpDrawable *drawable,
TempBuf *area)
{
PixelRegion destPR;
void *pr;
guchar *d;
int ulx, uly, offsetx, offsety, y;
GimpBrushPixmap *pixmap;
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush));
pixmap = GIMP_BRUSH_PIXMAP (paint_core->brush);
destPR.bytes = area->bytes;
destPR.x = 0; destPR.y = 0;
destPR.w = area->width;
destPR.h = area->height;
destPR.rowstride = destPR.bytes * area->width;
destPR.data = temp_buf_data (area);
pr = pixel_regions_register (1, &destPR);
/* Calculate upper left corner of brush as in
* paint_core_get_paint_area. Ugly to have to do this here, too.
*/
ulx = (int) paint_core->curx - (paint_core->brush->mask->width >> 1);
uly = (int) paint_core->cury - (paint_core->brush->mask->height >> 1);
offsetx = area->x - ulx;
offsety = area->y - uly;
for (; pr != NULL; pr = pixel_regions_process (pr))
{
d = destPR.data;
for (y = 0; y < destPR.h; y++)
{
paint_line_pixmap_mask (dest, drawable, pixmap,
d, offsetx, y + offsety,
destPR.bytes, destPR.w);
d += destPR.rowstride;
}
}
}
static void
paint_line_pixmap_mask (GImage *dest,
GimpDrawable *drawable,
GimpBrushPixmap *brush,
guchar *d,
int x,
int y,
int bytes,
int width)
{
guchar *b, *p;
int alpha;
int i;
/* Make sure x, y are positive */
while (x < 0)
x += brush->pixmap_mask->width;
while (y < 0)
y += brush->pixmap_mask->height;
/* Point to the approriate scanline */
b = temp_buf_data (brush->pixmap_mask) +
(y % brush->pixmap_mask->height) * brush->pixmap_mask->width * brush->pixmap_mask->bytes;
for (i = 0; i < width; i++)
{
p = b + ((i + x) % brush->pixmap_mask->width)
* brush->pixmap_mask->bytes;
d[bytes-1] = OPAQUE_OPACITY;
/* 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;
}
}

View file

@ -1,37 +1,63 @@
#ifndef __GIMP_BRUSH_PIPE_H__
#define __GIMP_BRUSH_PIPE_H__
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMPBRUSHPIPE_H__
#define __GIMPBRUSHPIPE_H__
#include "tools.h"
#include "paint_core.h"
#include "gimpbrush.h"
#include "gimpbrushpixmap.h"
#include "gimpbrush.h"
#include "gimpbrushlist.h"
#include "gimpbrushlistP.h"
#include "temp_buf.h"
typedef struct _GimpBrushPipe
typedef enum
{
GimpBrushPixmap pixmap_brush;
GimpBrushList *brush_list;
char * name;
char * filename;
} GimpBrushPipe;
PIPE_SELECT_INCREMENTAL,
PIPE_SELECT_DIRECTION,
PIPE_SELECT_VELOCITY,
PIPE_SELECT_RANDOM,
PIPE_SELECT_PRESSURE,
PIPE_SELECT_TILT_X,
PIPE_SELECT_TILT_Y
} PipeSelectModes;
typedef struct _GimpBrushPipeClass
{
GimpBrushPixmapClass parent_class;
void (* generate) (GimpBrushPipe *brush);
} GimpBrushPipeClass;
typedef struct _GimpBrushPixmap GimpBrushPixmap;
typedef struct _GimpBrushPipe GimpBrushPipe;
#define GIMP_TYPE_BRUSH_PIXMAP (gimp_brush_pixmap_get_type ())
#define GIMP_BRUSH_PIXMAP(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIXMAP, GimpBrushPixmap))
#define GIMP_IS_BRUSH_PIXMAP(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIXMAP))
/* object stuff */
#define GIMP_TYPE_BRUSH_PIPE (gimp_brush_pipe_get_type ())
#define GIMP_BRUSH_PIPE(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIPE, GimpBrushPipe))
#define GIMP_IS_BRUSH_PIPE(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIPE))
GtkType gimp_brush_pixmap_get_type (void);
GtkType gimp_brush_pipe_get_type (void);
GimpBrushPipe * gimp_brush_pipe_new (char *file_name);
GimpBrushPipe * gimp_brush_pipe_load (char *file_name);
GimpBrushPipe *gimp_brush_pipe_load (char *filename);
GimpBrushPipe *gimp_brush_pixmap_load (char *filename);
#endif /* __GIMPBRUSHPIPE_H__ */
TempBuf *gimp_brush_pixmap_pixmap (GimpBrushPixmap *);
void color_area_with_pixmap (PaintCore *paint_core,
GImage *dest,
GimpDrawable *drawable,
TempBuf *area);
#endif /* __GIMPBRUSHPIPE_H__ */

View file

@ -571,9 +571,7 @@ paint_options_init (PaintOptions *options,
_("Dodge or Burn Options") :
((tool_type == SMUDGE) ?
_("Smudge Options") :
((tool_type == PIXMAPBRUSH) ?
_("Pixmap Brush Options") :
_("ERROR: Unknown Paint Type"))))))))))))),
_("ERROR: Unknown Paint Type")))))))))))),
reset_func);
/* initialize the paint options structure */
@ -624,7 +622,6 @@ paint_options_init (PaintOptions *options,
case AIRBRUSH:
case CLONE:
case INK:
case PIXMAPBRUSH:
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
label = gtk_label_new (_("Mode:"));
@ -673,7 +670,6 @@ paint_options_init (PaintOptions *options,
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
@ -723,7 +719,6 @@ paint_options_init (PaintOptions *options,
case CONVOLVE:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
break;
default:
break;

View file

@ -344,7 +344,7 @@ help_quit_callback (GtkWidget *widget,
#ifdef NATIVE_WIN32
static char *
char *
quote_spaces (char *string)
{
int nspaces = 0;

View file

@ -33,6 +33,8 @@ enum{
LAST_SIGNAL
};
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
static guint gimp_brush_signals[LAST_SIGNAL];
static GimpObjectClass* parent_class;
@ -64,6 +66,8 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
klass->select_brush = gimp_brush_select_brush;
gimp_brush_signals[DIRTY] =
gimp_signal_new ("dirty", GTK_RUN_FIRST, type, 0, gimp_sigtype_void);
@ -116,6 +120,12 @@ gimp_brush_new (char *filename)
return brush;
}
static GimpBrush *
gimp_brush_select_brush (PaintCore *paint_core)
{
return paint_core->brush;
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{

View file

@ -20,12 +20,13 @@
#define __GIMPBRUSH_H__
#include <stdio.h>
#include "apptypes.h"
#include "gimpobjectP.h"
#include "paint_core.h"
#include "temp_buf.h"
#include "vector2d.h"
typedef struct _GimpBrush GimpBrush, * GimpBrushP;
struct _GimpBrush
{
GimpObject gobject;
@ -40,10 +41,10 @@ struct _GimpBrush
struct _GimpBrushClass
{
GimpObjectClass parent_class;
GimpBrush *(* select_brush) (PaintCore *);
};
typedef struct _GimpBrushClass GimpBrushClass;
#define BRUSH_CLASS(klass) \
#define GIMP_BRUSH_CLASS(klass) \
GTK_CHECK_CLASS_CAST (klass, gimp_brush_get_type(), GimpBrushClass)
#define GIMP_TYPE_BRUSH (gimp_brush_get_type ())

View file

@ -32,7 +32,6 @@
#include <math.h>
#include "appenv.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushgenerated.h"
#include "gimpbrushpipe.h"
#include "brush_header.h"
@ -173,12 +172,12 @@ brush_load(char *filename)
}
else if (strcmp(&filename[strlen(filename) - 4], ".gpb") == 0)
{
GimpBrushPixmap *brush;
GimpBrushPipe *brush;
brush = gimp_brush_pixmap_load(filename);
if (brush != NULL)
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
else
g_message("Warning: failed to load brush \"%s\"", filename);
g_message("Warning: failed to load pixmap brush \"%s\"", filename);
}
else if (strcmp(&filename[strlen(filename) - 4], ".gih") == 0)
{
@ -187,7 +186,7 @@ brush_load(char *filename)
if (brush != NULL)
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
else
g_message("Warning: failed to load pipe \"%s\"", filename);
g_message("Warning: failed to load pixmap pipe \"%s\"", filename);
}
}

View file

@ -1,33 +1,152 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "appenv.h"
#include "brush_header.h"
#include "pattern_header.h"
#include "patterns.h"
#include "gimpbrush.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushlist.h"
#include "gimpbrushpipe.h"
#include "gimpbrushpipeP.h"
#include "paint_core.h"
#include "gimprc.h"
#include "gimpbrushpipe.h"
#include "libgimp/gimpintl.h"
static void
gimp_brush_pipe_generate(GimpBrushPipe *brush);
static GimpBrushClass* gimp_brush_class;
static GtkObjectClass* gimp_object_class;
static GimpObjectClass* parent_class;
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
static void paint_line_pixmap_mask(GImage *dest,
GimpDrawable *drawable,
GimpBrushPixmap *brush,
guchar *d,
int x,
int y,
int bytes,
int width);
static void
gimp_brush_pixmap_destroy (GtkObject *object)
{
GimpBrushPixmap *pixmap;
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
pixmap = GIMP_BRUSH_PIXMAP (object);
temp_buf_free (pixmap->pixmap_mask);
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
}
static void
gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
{
GtkObjectClass *object_class;
GimpBrushClass *brush_class;
object_class = GTK_OBJECT_CLASS (klass);
brush_class = GIMP_BRUSH_CLASS (klass);
gimp_brush_class = gtk_type_class (gimp_brush_get_type ());
object_class->destroy = gimp_brush_pixmap_destroy;
brush_class->select_brush = gimp_brush_pixmap_select_brush;
}
void
gimp_brush_pixmap_init (GimpBrushPixmap *brush)
{
brush->pixmap_mask = NULL;
brush->pipe = NULL;
}
GtkType
gimp_brush_pixmap_get_type (void)
{
static GtkType type=0;
if(!type){
GtkTypeInfo info={
"GimpBrushPixmap",
sizeof (GimpBrushPixmap),
sizeof (GimpBrushPixmapClass),
(GtkClassInitFunc) gimp_brush_pixmap_class_init,
(GtkObjectInitFunc) gimp_brush_pixmap_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL};
type = gtk_type_unique (GIMP_TYPE_BRUSH, &info);
}
return type;
}
static GimpBrush *
gimp_brush_pixmap_select_brush (PaintCore *paint_core)
{
GimpBrushPixmap *pixmap;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), NULL);
pixmap = GIMP_BRUSH_PIXMAP (paint_core->brush);
if (pixmap->pipe->nbrushes == 1)
return GIMP_BRUSH (pixmap->pipe->current);
/* Just select the next one for now. This is the place where we
* will select the correct brush based on various parameters
* in paint_core.
*/
pixmap->pipe->index[0] = (pixmap->pipe->index[0] + 1) % pixmap->pipe->nbrushes;
pixmap->pipe->current = pixmap->pipe->brushes[pixmap->pipe->index[0]];
return GIMP_BRUSH (pixmap->pipe->current);
}
static void
gimp_brush_pipe_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy (object);
GimpBrushPipe *pipe;
int i;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_BRUSH_PIPE (object));
pipe = GIMP_BRUSH_PIPE (object);
g_free (pipe->rank);
for (i = 1; i < pipe->nbrushes; i++)
gimp_object_destroy (pipe->brushes[i]);
g_free (pipe->brushes);
g_free (pipe->select);
g_free (pipe->index);
if (GTK_OBJECT_CLASS (gimp_object_class)->destroy)
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
}
static void
@ -35,116 +154,294 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS(klass);
parent_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP);
object_class->destroy = gimp_brush_pipe_destroy;
object_class = GTK_OBJECT_CLASS (klass);
gimp_object_class = gtk_type_class (GIMP_TYPE_OBJECT);
object_class->destroy = gimp_brush_pipe_destroy;
}
void
gimp_brush_pipe_init(GimpBrushPipe *brush)
gimp_brush_pipe_init (GimpBrushPipe *pipe)
{
brush->name = NULL;
brush->filename = NULL;
brush->brush_list = gimp_brush_list_new();
pipe->dimension = 0;
pipe->rank = NULL;
pipe->nbrushes = 0;
pipe->select = NULL;
pipe->index = NULL;
}
GtkType gimp_brush_pipe_get_type(void)
GtkType
gimp_brush_pipe_get_type (void)
{
static GtkType type=0;
if(!type){
if (!type){
GtkTypeInfo info={
"GimpBrushPipe",
sizeof(GimpBrushPipe),
sizeof(GimpBrushPipeClass),
(GtkClassInitFunc)gimp_brush_pipe_class_init,
(GtkObjectInitFunc)gimp_brush_pipe_init,
/* reserved_1 */ NULL,
/* reserver_2 */ NULL,
sizeof (GimpBrushPipe),
sizeof (GimpBrushPipeClass),
(GtkClassInitFunc) gimp_brush_pipe_class_init,
(GtkObjectInitFunc) gimp_brush_pipe_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL};
type=gtk_type_unique(GIMP_TYPE_BRUSH_PIXMAP, &info);
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
}
return type;
}
GimpBrushPipe *
gimp_brush_pipe_load (char *file_name)
gimp_brush_pipe_load (char *filename)
{
GimpBrushPipe *pipe;
GimpBrushPixmap *brush;
GimpBrushList *list;
GPatternP pattern;
FILE *fp;
gchar buf2[1024];
guchar buf[1024];
guchar *name;
int num_of_brushes;
int brush_count=0;
guchar *params;
pipe = GIMP_BRUSH_PIPE(gimp_type_new(gimp_brush_pipe_get_type()));
GIMP_BRUSH_PIPE(pipe)->filename = g_strdup(file_name);
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
/* The file format starts with a painfully simple text header
* and we use a painfully simple way to read it
*/
if (fgets (buf, 1024, fp) == NULL)
{
fclose (fp);
return NULL;
}
buf[strlen (buf) - 1] = 0;
pipe = GIMP_BRUSH_PIPE (gimp_type_new (GIMP_TYPE_BRUSH_PIPE));
name = g_strdup (buf);
/* get the number of brushes */
if (fgets (buf, 1024, fp) == NULL)
{
fclose (fp);
gimp_object_destroy (pipe);
return NULL;
}
num_of_brushes = strtol(buf, &params, 10);
if (num_of_brushes < 1)
{
g_message (_("pixmap brush pipe should have at least one brush"));
fclose (fp);
gimp_object_destroy (pipe);
return NULL;
}
/* Here we should parse the params to get the dimension, ranks,
* placement options, etc. But just use defaults for now.
*/
pipe->dimension = 1;
pipe->rank = g_new (int, 1);
pipe->rank[0] = num_of_brushes;
pipe->select = g_new (PipeSelectModes, 1);
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
pipe->index = g_new (int, 1);
pipe->index[0] = 0;
pattern = (GPatternP) g_malloc (sizeof (GPattern));
pattern->filename = g_strdup (file_name);
pattern->filename = NULL;
pattern->name = NULL;
pattern->mask = NULL;
brush = GIMP_BRUSH_PIXMAP (pipe);
pipe->brushes =
(GimpBrushPixmap **) g_new0 (GimpBrushPixmap *, num_of_brushes);
list = gimp_brush_list_new();
/* First pixmap brush in the list is the pipe itself */
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
if ((fp = fopen(file_name, "rb")) == NULL)
return NULL;
/* the file format starts with a painfully simple text header
and we use a painfully simple way to read it */
if(fgets (buf2, 1024, fp) == NULL)
return NULL;
buf2[strlen(buf2) - 1] = '\0';
pipe->name = g_strdup(buf2);
/* Current pixmap brush is the first one. */
pipe->current = pipe->brushes[0];
/* get the number of brushes */
if(fgets (buf2, 1024, fp) == NULL)
return NULL;
num_of_brushes = strtol(buf2,NULL,10);
while(brush_count < num_of_brushes)
while (pipe->nbrushes < num_of_brushes)
{
if (brush_count > 0)
brush = GIMP_BRUSH_PIXMAP(gimp_type_new(gimp_brush_pixmap_get_type()));
GIMP_BRUSH(brush)->filename = g_strdup(file_name);
if (pipe->nbrushes > 0)
{
pipe->brushes[pipe->nbrushes] =
GIMP_BRUSH_PIXMAP (gimp_type_new (GIMP_TYPE_BRUSH_PIXMAP));
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
}
pipe->brushes[pipe->nbrushes]->pipe = pipe;
/* load the brush */
if(!gimp_brush_load_brush(GIMP_BRUSH(brush),fp,file_name))
{
g_message (_("failed to load a brush mask in the pipe"));
return NULL;
}
/* load the pattern data*/
if(!load_pattern_pattern(pattern, fp, file_name))
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[pipe->nbrushes]),
fp, filename)
|| !load_pattern_pattern (pattern, fp, filename))
{
g_message (_("failed to load a section of pixmap mask in the pipe"));
g_message (_("failed to load one of the pixmap brushes in the pipe"));
fclose (fp);
g_free (pattern);
gimp_object_destroy (pipe);
return NULL;
}
brush->pixmap_mask = pattern->mask;
gimp_brush_list_add(list,GIMP_BRUSH(brush));
brush_count++;
if (pipe->nbrushes == 0)
{
/* Replace name with the whole pipe's name */
GIMP_BRUSH (pipe)->name = name;
}
pipe->brushes[pipe->nbrushes]->pixmap_mask = pattern->mask;
pipe->nbrushes++;
}
/* Clean up */
fclose (fp);
if (!GIMP_IS_BRUSH_PIPE(pipe))
g_print ("Is not BRUSH_PIPE???\n");
pipe->brush_list = list;
g_free(pattern);
return pipe;
}
GimpBrushPipe *
gimp_brush_pixmap_load (char *filename)
{
GimpBrushPipe *pipe;
GPatternP pattern;
FILE *fp;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
pipe = GIMP_BRUSH_PIPE (gimp_type_new (GIMP_TYPE_BRUSH_PIPE));
/* A (single) pixmap brush is a pixmap pipe brush with just one pixmap */
pipe->dimension = 1;
pipe->rank = g_new (int, 1);
pipe->rank[0] = 1;
pipe->select = g_new (PipeSelectModes, 1);
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
pipe->index = g_new (int, 1);
pipe->index[0] = 0;
pattern = (GPatternP) g_malloc (sizeof (GPattern));
pattern->filename = NULL;
pattern->name = NULL;
pattern->mask = NULL;
pipe->brushes = (GimpBrushPixmap **) g_new (GimpBrushPixmap *, 1);
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
pipe->current = pipe->brushes[0];
pipe->brushes[0]->pipe = pipe;
/* load the brush */
if (!gimp_brush_load_brush (GIMP_BRUSH (pipe->brushes[0]),
fp, filename)
|| !load_pattern_pattern (pattern, fp, filename))
{
g_message (_("failed to load pixmap brush"));
fclose (fp);
g_free (pattern);
gimp_object_destroy (pipe);
return NULL;
}
pipe->brushes[0]->pixmap_mask = pattern->mask;
pipe->nbrushes = 1;
/* Clean up */
fclose (fp);
g_free(pattern);
return pipe;
}
TempBuf *
gimp_brush_pixmap_pixmap (GimpBrushPixmap *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (brush), NULL);
return brush->pixmap_mask;
}
void
color_area_with_pixmap (PaintCore *paint_core,
GImage *dest,
GimpDrawable *drawable,
TempBuf *area)
{
PixelRegion destPR;
void *pr;
guchar *d;
int ulx, uly, offsetx, offsety, y;
GimpBrushPixmap *pixmap;
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush));
pixmap = GIMP_BRUSH_PIXMAP (paint_core->brush);
destPR.bytes = area->bytes;
destPR.x = 0; destPR.y = 0;
destPR.w = area->width;
destPR.h = area->height;
destPR.rowstride = destPR.bytes * area->width;
destPR.data = temp_buf_data (area);
pr = pixel_regions_register (1, &destPR);
/* Calculate upper left corner of brush as in
* paint_core_get_paint_area. Ugly to have to do this here, too.
*/
ulx = (int) paint_core->curx - (paint_core->brush->mask->width >> 1);
uly = (int) paint_core->cury - (paint_core->brush->mask->height >> 1);
offsetx = area->x - ulx;
offsety = area->y - uly;
for (; pr != NULL; pr = pixel_regions_process (pr))
{
d = destPR.data;
for (y = 0; y < destPR.h; y++)
{
paint_line_pixmap_mask (dest, drawable, pixmap,
d, offsetx, y + offsety,
destPR.bytes, destPR.w);
d += destPR.rowstride;
}
}
}
static void
paint_line_pixmap_mask (GImage *dest,
GimpDrawable *drawable,
GimpBrushPixmap *brush,
guchar *d,
int x,
int y,
int bytes,
int width)
{
guchar *b, *p;
int alpha;
int i;
/* Make sure x, y are positive */
while (x < 0)
x += brush->pixmap_mask->width;
while (y < 0)
y += brush->pixmap_mask->height;
/* Point to the approriate scanline */
b = temp_buf_data (brush->pixmap_mask) +
(y % brush->pixmap_mask->height) * brush->pixmap_mask->width * brush->pixmap_mask->bytes;
for (i = 0; i < width; i++)
{
p = b + ((i + x) % brush->pixmap_mask->width)
* brush->pixmap_mask->bytes;
d[bytes-1] = OPAQUE_OPACITY;
/* 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;
}
}

View file

@ -1,37 +1,63 @@
#ifndef __GIMP_BRUSH_PIPE_H__
#define __GIMP_BRUSH_PIPE_H__
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMPBRUSHPIPE_H__
#define __GIMPBRUSHPIPE_H__
#include "tools.h"
#include "paint_core.h"
#include "gimpbrush.h"
#include "gimpbrushpixmap.h"
#include "gimpbrush.h"
#include "gimpbrushlist.h"
#include "gimpbrushlistP.h"
#include "temp_buf.h"
typedef struct _GimpBrushPipe
typedef enum
{
GimpBrushPixmap pixmap_brush;
GimpBrushList *brush_list;
char * name;
char * filename;
} GimpBrushPipe;
PIPE_SELECT_INCREMENTAL,
PIPE_SELECT_DIRECTION,
PIPE_SELECT_VELOCITY,
PIPE_SELECT_RANDOM,
PIPE_SELECT_PRESSURE,
PIPE_SELECT_TILT_X,
PIPE_SELECT_TILT_Y
} PipeSelectModes;
typedef struct _GimpBrushPipeClass
{
GimpBrushPixmapClass parent_class;
void (* generate) (GimpBrushPipe *brush);
} GimpBrushPipeClass;
typedef struct _GimpBrushPixmap GimpBrushPixmap;
typedef struct _GimpBrushPipe GimpBrushPipe;
#define GIMP_TYPE_BRUSH_PIXMAP (gimp_brush_pixmap_get_type ())
#define GIMP_BRUSH_PIXMAP(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIXMAP, GimpBrushPixmap))
#define GIMP_IS_BRUSH_PIXMAP(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIXMAP))
/* object stuff */
#define GIMP_TYPE_BRUSH_PIPE (gimp_brush_pipe_get_type ())
#define GIMP_BRUSH_PIPE(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PIPE, GimpBrushPipe))
#define GIMP_IS_BRUSH_PIPE(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_BRUSH_PIPE))
GtkType gimp_brush_pixmap_get_type (void);
GtkType gimp_brush_pipe_get_type (void);
GimpBrushPipe * gimp_brush_pipe_new (char *file_name);
GimpBrushPipe * gimp_brush_pipe_load (char *file_name);
GimpBrushPipe *gimp_brush_pipe_load (char *filename);
GimpBrushPipe *gimp_brush_pixmap_load (char *filename);
#endif /* __GIMPBRUSHPIPE_H__ */
TempBuf *gimp_brush_pixmap_pixmap (GimpBrushPixmap *);
void color_area_with_pixmap (PaintCore *paint_core,
GImage *dest,
GimpDrawable *drawable,
TempBuf *area);
#endif /* __GIMPBRUSHPIPE_H__ */

View file

@ -20,7 +20,7 @@
#include "appenv.h"
#include "actionarea.h"
#include "brush_scale.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "gimpbrushlist.h"
#include "gimpcontext.h"
#include "gimplist.h"
@ -736,7 +736,7 @@ brush_popup_timeout (gpointer data)
if (GIMP_IS_BRUSH_PIXMAP (brush))
{
GimpBrushPixmap *pixmapbrush = GIMP_BRUSH_PIXMAP(brush);
src = (gchar *) temp_buf_data (pixmapbrush->pixmap_mask);
src = (gchar *) temp_buf_data (gimp_brush_pixmap_pixmap (pixmapbrush));
for (y = 0; y < brush->mask->height; y++)
{
gtk_preview_draw_row (GTK_PREVIEW (bsp->brush_preview), (guchar *)src,
@ -817,8 +817,9 @@ display_brush (BrushSelectP bsp,
int ystart;
int i, j;
brush_buf = GIMP_IS_BRUSH_PIXMAP (brush) ? GIMP_BRUSH_PIXMAP(brush)->pixmap_mask
: brush->mask;
brush_buf = GIMP_IS_BRUSH_PIXMAP (brush) ?
gimp_brush_pixmap_pixmap (GIMP_BRUSH_PIXMAP(brush))
: brush->mask;
if (brush_buf->width > bsp->cell_width || brush_buf->height > bsp->cell_height)
{

View file

@ -344,7 +344,7 @@ help_quit_callback (GtkWidget *widget,
#ifdef NATIVE_WIN32
static char *
char *
quote_spaces (char *string)
{
int nspaces = 0;

View file

@ -344,7 +344,7 @@ help_quit_callback (GtkWidget *widget,
#ifdef NATIVE_WIN32
static char *
char *
quote_spaces (char *string)
{
int nspaces = 0;

View file

@ -136,7 +136,6 @@ gimp_OBJECTS = \
gimpbrushgenerated.o \
gimpbrushlist.o \
gimpbrushpipe.o \
gimpbrushpixmap.o \
gimpcontext.o \
gimpdnd.o \
gimphistogram.o \
@ -203,7 +202,6 @@ gimp_OBJECTS = \
perspective_tool.o \
pixel_processor.o \
pixel_region.o \
pixmapbrush.o \
plug_in.o \
plug_in_cmds.o \
posterize.o \

View file

@ -143,7 +143,6 @@ gimp_OBJECTS = \
gimpbrushgenerated.obj \
gimpbrushlist.obj \
gimpbrushpipe.obj \
gimpbrushpixmap.obj \
gimpcontext.obj \
gimpdnd.obj \
gimphistogram.obj \
@ -210,7 +209,6 @@ gimp_OBJECTS = \
perspective_tool.obj \
pixel_processor.obj \
pixel_region.obj \
pixmapbrush.obj \
plug_in.obj \
plug_in_cmds.obj \
posterize.obj \

View file

@ -18,7 +18,7 @@
#include <stdlib.h>
#include "appenv.h"
#include "gimpbrushlist.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
@ -26,8 +26,6 @@
#include "paint_core.h"
#include "paint_options.h"
#include "palette.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "airbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
@ -293,23 +291,19 @@ airbrush_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* color the pixels */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -20,15 +20,13 @@
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "paint_funcs.h"
#include "paint_core.h"
#include "paint_options.h"
#include "paintbrush.h"
#include "palette.h"
#include "pencil.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "selection.h"
#include "tools.h"
@ -120,25 +118,21 @@ pencil_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
/* Get a region which can be used to paint to */
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* set the alpha channel */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
/* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
paint_appl_mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -272,7 +272,12 @@ paint_core_button_press (Tool *tool,
paint_core->lastytilt = paint_core->curytilt;
}
else
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
{
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
}
gdisplay_flush_now (gdisp);
}
@ -750,6 +755,9 @@ paint_core_interpolate (PaintCore *paint_core,
paint_core->curpressure = paint_core->lastpressure + dpressure * t;
paint_core->curxtilt = paint_core->lastxtilt + dxtilt * t;
paint_core->curytilt = paint_core->lastytilt + dytilt * t;
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
}
}

View file

@ -32,8 +32,6 @@
#define FINISH_PAINT 4
typedef struct _paint_core PaintCore;
typedef void * (* PaintFunc) (PaintCore *, GimpDrawable *, int);
struct _paint_core
{

View file

@ -23,15 +23,14 @@
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "gimpbrushpipe.h"
#include "gimpbrushlist.h"
#include "gimpbrushpipe.h"
#include "gradient.h"
#include "paint_funcs.h"
#include "paint_core.h"
#include "palette.h"
#include "paint_options.h"
#include "paintbrush.h"
#include "pixmapbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
@ -441,7 +440,7 @@ paintbrush_motion (PaintCore *paint_core,
pixmap image into the are instead of the color */
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length)
{
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
paint_appl_mode = INCREMENTAL;
}
else

View file

@ -20,15 +20,13 @@
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "paint_funcs.h"
#include "paint_core.h"
#include "paint_options.h"
#include "paintbrush.h"
#include "palette.h"
#include "pencil.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "selection.h"
#include "tools.h"
@ -120,25 +118,21 @@ pencil_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
/* Get a region which can be used to paint to */
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* set the alpha channel */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
/* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
paint_appl_mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -571,9 +571,7 @@ paint_options_init (PaintOptions *options,
_("Dodge or Burn Options") :
((tool_type == SMUDGE) ?
_("Smudge Options") :
((tool_type == PIXMAPBRUSH) ?
_("Pixmap Brush Options") :
_("ERROR: Unknown Paint Type"))))))))))))),
_("ERROR: Unknown Paint Type")))))))))))),
reset_func);
/* initialize the paint options structure */
@ -624,7 +622,6 @@ paint_options_init (PaintOptions *options,
case AIRBRUSH:
case CLONE:
case INK:
case PIXMAPBRUSH:
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
label = gtk_label_new (_("Mode:"));
@ -673,7 +670,6 @@ paint_options_init (PaintOptions *options,
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
@ -723,7 +719,6 @@ paint_options_init (PaintOptions *options,
case CONVOLVE:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
break;
default:
break;

View file

@ -49,7 +49,6 @@
#include "move.h"
#include "paintbrush.h"
#include "pencil.h"
#include "pixmapbrush.h"
#include "posterize.h"
#include "rect_select.h"
#include "session.h"
@ -483,21 +482,6 @@ ToolInfo tool_info[] =
NULL
},
{
NULL,
N_("Pixmap brush"),
16,
N_("/Tools/Pixmap Brush"),
"",
(char **) paint_bits,
N_("Paint fuzzy brush strokes"),
"ContextHelp/paintbrush",
PIXMAPBRUSH,
tools_new_pixmapbrush,
tools_free_pixmapbrush,
NULL
},
{
NULL,
N_("Measure"),

View file

@ -18,7 +18,7 @@
#include <stdlib.h>
#include "appenv.h"
#include "gimpbrushlist.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
@ -26,8 +26,6 @@
#include "paint_core.h"
#include "paint_options.h"
#include "palette.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "airbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
@ -293,23 +291,19 @@ airbrush_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* color the pixels */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -18,7 +18,7 @@
#include <stdlib.h>
#include "appenv.h"
#include "gimpbrushlist.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
@ -26,8 +26,6 @@
#include "paint_core.h"
#include "paint_options.h"
#include "palette.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "airbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
@ -293,23 +291,19 @@ airbrush_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* color the pixels */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -20,15 +20,13 @@
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "paint_funcs.h"
#include "paint_core.h"
#include "paint_options.h"
#include "paintbrush.h"
#include "palette.h"
#include "pencil.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "selection.h"
#include "tools.h"
@ -120,25 +118,21 @@ pencil_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
/* Get a region which can be used to paint to */
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* set the alpha channel */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
/* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
paint_appl_mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -272,7 +272,12 @@ paint_core_button_press (Tool *tool,
paint_core->lastytilt = paint_core->curytilt;
}
else
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
{
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
}
gdisplay_flush_now (gdisp);
}
@ -750,6 +755,9 @@ paint_core_interpolate (PaintCore *paint_core,
paint_core->curpressure = paint_core->lastpressure + dpressure * t;
paint_core->curxtilt = paint_core->lastxtilt + dxtilt * t;
paint_core->curytilt = paint_core->lastytilt + dytilt * t;
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
}
}

View file

@ -32,8 +32,6 @@
#define FINISH_PAINT 4
typedef struct _paint_core PaintCore;
typedef void * (* PaintFunc) (PaintCore *, GimpDrawable *, int);
struct _paint_core
{

View file

@ -23,15 +23,14 @@
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "gimpbrushpipe.h"
#include "gimpbrushlist.h"
#include "gimpbrushpipe.h"
#include "gradient.h"
#include "paint_funcs.h"
#include "paint_core.h"
#include "palette.h"
#include "paint_options.h"
#include "paintbrush.h"
#include "pixmapbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
@ -441,7 +440,7 @@ paintbrush_motion (PaintCore *paint_core,
pixmap image into the are instead of the color */
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush) && !gradient_length)
{
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
paint_appl_mode = INCREMENTAL;
}
else

View file

@ -20,15 +20,13 @@
#include "drawable.h"
#include "errors.h"
#include "gdisplay.h"
#include "gimpbrushpixmap.h"
#include "gimpbrushpipe.h"
#include "paint_funcs.h"
#include "paint_core.h"
#include "paint_options.h"
#include "paintbrush.h"
#include "palette.h"
#include "pencil.h"
/* for color_area_with_pixmap */
#include "pixmapbrush.h"
#include "selection.h"
#include "tools.h"
@ -120,25 +118,21 @@ pencil_motion (PaintCore *paint_core,
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable, col);
/* Get a region which can be used to paint to */
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* set the alpha channel */
col[area->bytes - 1] = OPAQUE_OPACITY;
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
/* if its a pixmap, do pixmap stuff */
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (paint_core, gimage, drawable, area);
paint_appl_mode = INCREMENTAL;
}
else
{
/* color the pixels */
gimage_get_foreground (gimage, drawable, col);
col[area->bytes - 1] = OPAQUE_OPACITY;
color_pixels (temp_buf_data (area), col,
area->width * area->height, area->bytes);
}

View file

@ -571,9 +571,7 @@ paint_options_init (PaintOptions *options,
_("Dodge or Burn Options") :
((tool_type == SMUDGE) ?
_("Smudge Options") :
((tool_type == PIXMAPBRUSH) ?
_("Pixmap Brush Options") :
_("ERROR: Unknown Paint Type"))))))))))))),
_("ERROR: Unknown Paint Type")))))))))))),
reset_func);
/* initialize the paint options structure */
@ -624,7 +622,6 @@ paint_options_init (PaintOptions *options,
case AIRBRUSH:
case CLONE:
case INK:
case PIXMAPBRUSH:
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
label = gtk_label_new (_("Mode:"));
@ -673,7 +670,6 @@ paint_options_init (PaintOptions *options,
case INK:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
@ -723,7 +719,6 @@ paint_options_init (PaintOptions *options,
case CONVOLVE:
case DODGEBURN:
case SMUDGE:
case PIXMAPBRUSH:
break;
default:
break;

View file

@ -49,7 +49,6 @@
#include "move.h"
#include "paintbrush.h"
#include "pencil.h"
#include "pixmapbrush.h"
#include "posterize.h"
#include "rect_select.h"
#include "session.h"
@ -483,21 +482,6 @@ ToolInfo tool_info[] =
NULL
},
{
NULL,
N_("Pixmap brush"),
16,
N_("/Tools/Pixmap Brush"),
"",
(char **) paint_bits,
N_("Paint fuzzy brush strokes"),
"ContextHelp/paintbrush",
PIXMAPBRUSH,
tools_new_pixmapbrush,
tools_free_pixmapbrush,
NULL
},
{
NULL,
N_("Measure"),

View file

@ -64,7 +64,6 @@ typedef enum
INK,
DODGEBURN,
SMUDGE,
PIXMAPBRUSH,
MEASURE,
LAST_TOOLBOX_TOOL = MEASURE,

View file

@ -344,7 +344,7 @@ help_quit_callback (GtkWidget *widget,
#ifdef NATIVE_WIN32
static char *
char *
quote_spaces (char *string)
{
int nspaces = 0;

View file

@ -2,6 +2,10 @@ EXPORTS
gimp_brush_select_widget
gimp_brush_select_widget_close_popup
gimp_brush_select_widget_set_popup
gimp_chain_button_get_active
gimp_chain_button_get_type
gimp_chain_button_new
gimp_chain_button_set_active
gimp_channel_menu_new
gimp_drawable_menu_new
gimp_file_selection_get_filename
@ -12,12 +16,28 @@ EXPORTS
gimp_gradient_select_widget_close_popup
gimp_gradient_select_widget_set_popup
gimp_image_menu_new
gimp_layer_menu_new
gimp_interactive_selection_brush
gimp_interactive_selection_pattern
gimp_layer_menu_new
gimp_pattern_close_popup
gimp_pattern_get_pattern_data
gimp_pattern_select_widget
gimp_pattern_select_widget_close_popup
gimp_pattern_select_widget_set_popup
gimp_pattern_set_popup
gimp_size_entry_add_field
gimp_size_entry_attach_label
gimp_size_entry_get_refval
gimp_size_entry_get_type
gimp_size_entry_get_unit
gimp_size_entry_get_value
gimp_size_entry_grab_focus
gimp_size_entry_new
gimp_size_entry_set_refval
gimp_size_entry_set_refval_boundaries
gimp_size_entry_set_refval_digits
gimp_size_entry_set_resolution
gimp_size_entry_set_size
gimp_size_entry_set_unit
gimp_size_entry_set_value
gimp_size_entry_set_value_boundaries

View file

@ -129,9 +129,12 @@ parasite.o : parasite.c
gimpui_OBJECTS = \
gimpmenu.o \
gimpbrushmenu.o \
gimpfileselection.o\
gimpgradientmenu.o\
gimppatternmenu.o
gimpchainbutton.o \
gimpfileselection.o \
gimpgradientmenu.o \
gimppatternmenu.o \
gimpsizeentry.o \
gimpunitmenu.o
gimpui-$(GIMP_VER).dll : $(gimpui_OBJECTS) gimpui.def
$(GLIB)/build-dll gimpui $(GIMP_VER) gimpui.def -s $(gimpui_OBJECTS) -L . -lgimp-$(GIMP_VER) -L $(GTK)/gtk -lgtk-$(GTK_VER) -L $(GTK)/gdk/win32 -lgdk-$(GTK_VER) -L $(INTL) -lgnu-intl -L $(GLIB) -lglib-$(GLIB_VER)

View file

@ -135,9 +135,12 @@ parasite.obj : parasite.c
gimpui_OBJECTS = \
gimpmenu.obj \
gimpbrushmenu.obj\
gimpchainbutton.obj\
gimpfileselection.obj\
gimpgradientmenu.obj\
gimppatternmenu.obj
gimppatternmenu.obj\
gimpsizeentry.obj\
gimpunitmenu.obj
gimpui-$(GIMP_VER).dll : $(gimpui_OBJECTS) gimpui.def
$(CC) $(CFLAGS) -LD -Fegimpui-$(GIMP_VER).dll $(gimpui_OBJECTS) gimp-$(GIMP_VER).lib $(GTK)\gtk\gtk-$(GTK_VER).lib $(GTK)\gdk\win32\gdk-$(GTK_VER).lib $(INTL)\gnu-intl.lib $(GLIB)\glib-$(GLIB_VER).lib $(LDFLAGS) /def:gimpui.def

View file

@ -1,6 +1,6 @@
/* Plug-in to save .gpb (GIMP Pixmap Brush) files.
* This is probably only of temporary interest, the format for
* pixmap brushes is likely to change.
* The format for pixmap brushes might well change, and this will have to
* be updated.
*
* Copyright (C) 1999 Tor Lillqvist
*