mirror of https://github.com/GNOME/gimp.git
app/pixmapbrush.c app/pixmapbrush.h app/gimpbrushpixmap.c New files,
Mon Aug 9 01:20:24 1999 Adrian Likins <alikins@redhat.com> * app/pixmapbrush.c * app/pixmapbrush.h * app/gimpbrushpixmap.c * app/gimpbrushpixmap.h: New files, implement the GimpBrushPixmap object, and the pixmap brush tool. * app/context_manager.c * app/tool_options.c * app/tools.c * app/toolsF.h: add the pixmap brush tool in * app/gimpbrushlist.c: allow for loading of pixmap brushes and displaying them in the brush dialog. Currently it only shows the grey scale mask. *app/Makefile.am: add the pixmap tool stuff to the build process These Changes implement a pixmap brush tool. Sort of a "image stamp". Some examples can be seen at http://adrian.gimp.org/pixmap-brush/. Some examples of pixmap brushes can be found there too (.gpb extension), but these are easy enough to make (for now, make a pattern and a brush the same size and `cat foo.gbr foo.pat > foo.gpb` ;-> Theres still a few rough edges that need some tweaking, but the framework is there. Figured I'd sneak it in before the freeze.
This commit is contained in:
parent
35cd255e27
commit
204d4123b2
31
ChangeLog
31
ChangeLog
|
@ -1,3 +1,34 @@
|
|||
Mon Aug 9 01:20:24 1999 Adrian Likins <alikins@redhat.com>
|
||||
|
||||
* app/pixmapbrush.c
|
||||
* app/pixmapbrush.h
|
||||
* app/gimpbrushpixmap.c
|
||||
* app/gimpbrushpixmap.h: New files, implement the GimpBrushPixmap
|
||||
object, and the pixmap brush tool.
|
||||
|
||||
* app/context_manager.c
|
||||
* app/tool_options.c
|
||||
* app/tools.c
|
||||
* app/toolsF.h: add the pixmap brush tool in
|
||||
|
||||
* app/gimpbrushlist.c: allow for loading of pixmap brushes and
|
||||
displaying them in the brush dialog. Currently it only shows the
|
||||
grey scale mask.
|
||||
|
||||
*app/Makefile.am: add the pixmap tool stuff to the build process
|
||||
|
||||
These Changes implement a pixmap brush tool. Sort of a "image stamp".
|
||||
Some examples can be seen at http://adrian.gimp.org/pixmap-brush/.
|
||||
|
||||
Some examples of pixmap brushes can be found there too (.gpb
|
||||
extension), but these are easy enough to make (for now, make
|
||||
a pattern and a brush the same size and `cat foo.gbr foo.pat >
|
||||
foo.gpb` ;->
|
||||
|
||||
Theres still a few rough edges that need some tweaking, but
|
||||
the framework is there. Figured I'd sneak it in before the
|
||||
freeze.
|
||||
|
||||
1999-08-08 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* plug-ins/common/winclipboard.c: New Windows-only plug-in, an
|
||||
|
|
|
@ -185,6 +185,8 @@ gimp_SOURCES = \
|
|||
gimpbrush.h \
|
||||
gimpbrushgenerated.c \
|
||||
gimpbrushgenerated.h \
|
||||
gimpbrushpixmap.c \
|
||||
gimpbrushpixmap.h \
|
||||
gimpbrushlist.c \
|
||||
gimpbrushlist.h \
|
||||
gimpbrushlistF.h \
|
||||
|
@ -320,6 +322,8 @@ gimp_SOURCES = \
|
|||
pixel_region.c \
|
||||
pixel_region.h \
|
||||
pixel_regionP.h \
|
||||
pixmapbrush.c \
|
||||
pixmapbrush.h \
|
||||
pixmaps.h \
|
||||
pixmaps2.h \
|
||||
plug_in.c \
|
||||
|
|
|
@ -92,6 +92,7 @@ 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;
|
||||
|
|
|
@ -570,7 +570,9 @@ paint_options_init (PaintOptions *options,
|
|||
_("Dodge or Burn Options") :
|
||||
((tool_type == SMUDGE) ?
|
||||
_("Smudge Options") :
|
||||
_("ERROR: Unknown Paint Type")))))))))))),
|
||||
((tool_type == PIXMAPBRUSH) ?
|
||||
_("Pixmap Brush Ootions") :
|
||||
_("ERROR: Unknown Paint Type"))))))))))))),
|
||||
reset_func);
|
||||
|
||||
/* initialize the paint options structure */
|
||||
|
@ -618,6 +620,7 @@ 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:"));
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gimpbrushpixmap.h"
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "brush_header.h"
|
||||
#include "brush_select.h"
|
||||
|
@ -151,23 +152,32 @@ static void
|
|||
brush_load(char *filename)
|
||||
{
|
||||
if (strcmp(&filename[strlen(filename) - 4], ".gbr") == 0)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
brush = gimp_brush_new(filename);
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add(brush_list, brush);
|
||||
else
|
||||
g_message("Warning: failed to load brush \"%s\"", filename);
|
||||
}
|
||||
{
|
||||
GimpBrush *brush;
|
||||
brush = gimp_brush_new(filename);
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add(brush_list, brush);
|
||||
else
|
||||
g_message("Warning: failed to load brush \"%s\"", filename);
|
||||
}
|
||||
else if (strcmp(&filename[strlen(filename) - 4], ".vbr") == 0)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
brush = gimp_brush_generated_load(filename);
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
|
||||
else
|
||||
g_message("Warning: failed to load brush \"%s\"", filename);
|
||||
}
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
brush = gimp_brush_generated_load(filename);
|
||||
if (brush != NULL)
|
||||
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
|
||||
else
|
||||
g_message("Warning: failed to load brush \"%s\"", filename);
|
||||
}
|
||||
else if (strcmp(&filename[strlen(filename) - 4], ".gpb") == 0)
|
||||
{
|
||||
GimpBrushPixmap *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);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "brush_header.h"
|
||||
#include "pattern_header.h"
|
||||
#include "gimpbrushpixmap.h"
|
||||
#include "paint_core.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
static void
|
||||
gimp_brush_pixmap_generate(GimpBrushPixmap *brush);
|
||||
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
|
||||
static void
|
||||
gimp_brush_pixmap_destroy(GtkObject *object)
|
||||
{
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS(klass);
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_BRUSH);
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_pixmap_init(GimpBrushPixmap *brush)
|
||||
{
|
||||
brush->pixmap_mask = NULL;
|
||||
}
|
||||
|
||||
guint gimp_brush_pixmap_get_type(void)
|
||||
{
|
||||
static GtkType type;
|
||||
if(!type){
|
||||
GtkTypeInfo info={
|
||||
"GimpBrushPixmap",
|
||||
sizeof(GimpBrushPixmap),
|
||||
sizeof(GimpBrushPixmapClass),
|
||||
(GtkClassInitFunc)gimp_brush_pixmap_class_init,
|
||||
(GtkObjectInitFunc)gimp_brush_pixmap_init,
|
||||
NULL,
|
||||
NULL };
|
||||
type=gtk_type_unique(GIMP_TYPE_BRUSH, &info);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
TempBuf *
|
||||
gimp_brush_pixmap_get_pixmap (GimpBrushPixmap* brush)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP(brush), NULL);
|
||||
return brush->pixmap_mask;
|
||||
}
|
||||
|
||||
GimpBrushPixmap *
|
||||
gimp_brush_pixmap_load (char *file_name)
|
||||
{
|
||||
GimpBrushPixmap *brush;
|
||||
FILE *fp;
|
||||
char string[256];
|
||||
float fl;
|
||||
float version;
|
||||
unsigned char buf[sz_BrushHeader];
|
||||
BrushHeader header;
|
||||
int bn_size;
|
||||
unsigned int * hp;
|
||||
char * nothing;
|
||||
int i;
|
||||
|
||||
|
||||
brush = GIMP_BRUSH_PIXMAP(gimp_type_new(gimp_brush_pixmap_get_type()));
|
||||
GIMP_BRUSH(brush)->filename = g_strdup (file_name);
|
||||
|
||||
if ((fp =fopen(file_name, "rb")) == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* we read in the brush mask first */
|
||||
|
||||
/* Read in the header size */
|
||||
if ((fread (buf, 1, sz_BrushHeader, fp)) < sz_BrushHeader)
|
||||
{
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
hp = (unsigned int *) &header;
|
||||
for (i = 0; i < (sz_BrushHeader / 4); i++)
|
||||
hp [i] = (buf [i * 4] << 24) + (buf [i * 4 + 1] << 16) +
|
||||
(buf [i * 4 + 2] << 8) + (buf [i * 4 + 3]);
|
||||
|
||||
|
||||
/* Check for correct file format */
|
||||
if (header.magic_number != GBRUSH_MAGIC)
|
||||
{
|
||||
/* One thing that can save this error is if the brush is version 1 */
|
||||
if (header.version != 1)
|
||||
{
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (header.version == 1)
|
||||
{
|
||||
/* If this is a version 1 brush, set the fp back 8 bytes */
|
||||
fseek (fp, -8, SEEK_CUR);
|
||||
header.header_size += 8;
|
||||
/* spacing is not defined in version 1 */
|
||||
header.spacing = 25;
|
||||
}
|
||||
|
||||
|
||||
/* Read in the brush name */
|
||||
if ((bn_size = (header.header_size - sz_BrushHeader)))
|
||||
{
|
||||
GIMP_BRUSH(brush)->name = (char *) g_malloc (sizeof (char) * bn_size);
|
||||
if ((fread (GIMP_BRUSH(brush)->name, 1, bn_size, fp)) < bn_size)
|
||||
{
|
||||
g_message ("Error in GIMP brush file...aborting.");
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
switch(header.version)
|
||||
{
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
GIMP_BRUSH(brush)->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
/* Read the brush mask data */
|
||||
|
||||
if ((fread (temp_buf_data (GIMP_BRUSH(brush)->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message ("GIMP brush file appears to be truncated.");
|
||||
|
||||
break;
|
||||
default:
|
||||
g_message ("Unknown brush format version #%d in \"%s\"\n",
|
||||
header.version, file_name);
|
||||
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* PATTERN STUFF HERE */
|
||||
/* Read in the header size */
|
||||
if ((fread (buf, 1, sz_PatternHeader, fp)) < sz_PatternHeader)
|
||||
{
|
||||
fclose (fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
hp = (unsigned int *) &header;
|
||||
for (i = 0; i < (sz_PatternHeader / 4); i++)
|
||||
hp [i] = (buf [i * 4] << 24) + (buf [i * 4 + 1] << 16) +
|
||||
(buf [i * 4 + 2] << 8) + (buf [i * 4 + 3]);
|
||||
|
||||
|
||||
brush->pixmap_mask = temp_buf_new (header.width, header.height, header.bytes, 0, 0, NULL);
|
||||
|
||||
|
||||
/* Read in the pattern name */
|
||||
if ((bn_size = (header.header_size - sz_PatternHeader)))
|
||||
{
|
||||
|
||||
nothing = (char *) g_malloc (sizeof (char) * bn_size);
|
||||
if ((fread (nothing, 1, bn_size, fp)) < bn_size)
|
||||
{
|
||||
g_message ("Error in GIMP pattern file...aborting.");
|
||||
fclose (fp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
nothing = g_strdup ("Unnamed");
|
||||
}
|
||||
|
||||
|
||||
if ((fread (temp_buf_data (brush->pixmap_mask), 1,
|
||||
header.width * header.height * header.bytes, fp))
|
||||
< header.width * header.height * header.bytes)
|
||||
g_message ("GIMP pattern file appears to be truncated.");
|
||||
|
||||
/* Clean up */
|
||||
fclose (fp);
|
||||
|
||||
return GIMP_BRUSH(brush);
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef __GIMP_BRUSH_PIXMAP_H__
|
||||
#define __GIMP_BRUSH_PIXMAP_H__
|
||||
|
||||
#include "gimpbrush.h"
|
||||
|
||||
typedef struct _GimpBrushPixmap
|
||||
{
|
||||
GimpBrush gbrush;
|
||||
TempBuf * pixmap_mask;
|
||||
} GimpBrushPixmap;
|
||||
|
||||
typedef struct _GimpBrushPixmapClass
|
||||
{
|
||||
GimpBrushClass parent_class;
|
||||
|
||||
void (* generate) (GimpBrushPixmap *brush);
|
||||
} GimpBrushPixmapClass;
|
||||
|
||||
/* object stuff */
|
||||
#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))
|
||||
|
||||
guint gimp_brush_pixmap_get_type (void);
|
||||
|
||||
GimpBrushPixmap * gimp_brush_pixmap_new (char *filename);
|
||||
GimpBrushPixmap * gimp_brush_pixmap_load (char *filename);
|
||||
|
||||
TempBuf * gimp_brush_pixmap_get_pixmap (GimpBrushPixmap* brush);
|
||||
#endif /* __GIMPPIXMAPBRUSH_H__ */
|
|
@ -0,0 +1,375 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "appenv.h"
|
||||
#include "gimpbrushpixmap.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "drawable.h"
|
||||
#include "errors.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gradient.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "paint_core.h"
|
||||
#include "palette.h"
|
||||
#include "paintbrush.h"
|
||||
#include "paint_options.h"
|
||||
#include "pixmapbrush.h"
|
||||
#include "selection.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
/* forward function declarations */
|
||||
static void pixmapbrush_motion (PaintCore *, GimpDrawable *, double, double, gboolean);
|
||||
/* static Argument * pixmapbrush_invoker (Argument *); */
|
||||
/* static Argument * pixmapbrush_extended_invoker (Argument *); */
|
||||
/* static Argument * pixmapbrush_extended_gradient_invoker (Argument *); */
|
||||
static double non_gui_fade_out,non_gui_gradient_length, non_gui_incremental;
|
||||
|
||||
static void paint_line_pixmap_mask (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GimpBrushPixmap *brush,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
int y2,
|
||||
int bytes,
|
||||
int width);
|
||||
|
||||
|
||||
/* defines */
|
||||
#define PAINT_LEFT_THRESHOLD 0.05
|
||||
|
||||
typedef struct _PixmapPaintOptions PixmapPaintOptions;
|
||||
struct _PixmapPaintOptions
|
||||
{
|
||||
|
||||
PaintOptions paint_options;
|
||||
|
||||
double fade_out;
|
||||
double gradient_length;
|
||||
gboolean incremental;
|
||||
};
|
||||
|
||||
/* local variables */
|
||||
static PixmapPaintOptions *pixmap_paint_options = NULL;
|
||||
|
||||
|
||||
static void
|
||||
pixmapbrush_toggle_update (GtkWidget *w,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean *toggle_val;
|
||||
|
||||
toggle_val = (gboolean *) data;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (w)->active)
|
||||
*toggle_val = TRUE;
|
||||
else
|
||||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
pixmapbrush_scale_update (GtkAdjustment *adjustment,
|
||||
PixmapPaintOptions *options)
|
||||
{
|
||||
options->gradient_length = adjustment->value;
|
||||
if(options->gradient_length > 0.0)
|
||||
options->incremental = INCREMENTAL;
|
||||
}
|
||||
|
||||
static void
|
||||
pixmapbrush_fade_update (GtkAdjustment *adjustment,
|
||||
PixmapPaintOptions *options)
|
||||
{
|
||||
options->fade_out = adjustment->value;
|
||||
}
|
||||
|
||||
static void
|
||||
pixmapbrush_options_reset (void)
|
||||
{
|
||||
PixmapPaintOptions *options = pixmap_paint_options;
|
||||
|
||||
paint_options_reset ((PaintOptions *) options);
|
||||
|
||||
}
|
||||
|
||||
static PixmapPaintOptions *
|
||||
pixmapbrush_options_new (void)
|
||||
{
|
||||
PixmapPaintOptions *options;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *fade_out_scale;
|
||||
GtkObject *fade_out_scale_data;
|
||||
GtkWidget *gradient_length_scale;
|
||||
GtkObject *gradient_length_scale_data;
|
||||
GtkWidget *incremental_toggle;
|
||||
|
||||
|
||||
/* the new options structure */
|
||||
options = (PixmapPaintOptions *) g_malloc (sizeof (PixmapPaintOptions));
|
||||
paint_options_init ((PaintOptions *) options,
|
||||
PIXMAPBRUSH,
|
||||
pixmapbrush_options_reset);
|
||||
|
||||
options->fade_out = 0.0;
|
||||
options->incremental = FALSE;
|
||||
options->gradient_length = 0.0;
|
||||
|
||||
/* the main vbox */
|
||||
/* vbox = gtk_vbox_new (FALSE, 1); */
|
||||
vbox = ((ToolOptions *) options)->main_vbox;
|
||||
|
||||
/* the main label */
|
||||
label = gtk_label_new (_("Pixmapbrush Options"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* the fade-out scale */
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new (_("Fade Out"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
#define USE_SPEEDSHOP_CALIPERS 0
|
||||
#define TIMED_BRUSH 0
|
||||
|
||||
#if USE_SPEEDSHOP_CALIPERS
|
||||
#include <SpeedShop/api.h>
|
||||
#endif
|
||||
|
||||
void *
|
||||
pixmap_paint_func (PaintCore *paint_core,
|
||||
GimpDrawable *drawable,
|
||||
int state)
|
||||
{
|
||||
#if TIMED_BRUSH
|
||||
static GTimer *timer;
|
||||
#endif
|
||||
switch (state)
|
||||
{
|
||||
case INIT_PAINT :
|
||||
#if TIMED_BRUSH
|
||||
timer = g_timer_new();
|
||||
g_timer_start(timer);
|
||||
#if USE_SPEEDSHOP_CALIPERS
|
||||
ssrt_caliper_point(0, "Painting");
|
||||
#endif /* USE_SPEEDSHOP_CALIPERS */
|
||||
#endif /* TIMED_BRUSH */
|
||||
break;
|
||||
|
||||
case MOTION_PAINT :
|
||||
pixmapbrush_motion (paint_core, drawable,
|
||||
pixmap_paint_options->fade_out,
|
||||
pixmap_paint_options->gradient_length,
|
||||
pixmap_paint_options->incremental);
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
#if TIMED_BRUSH
|
||||
#if USE_SPEEDSHOP_CALIPERS
|
||||
ssrt_caliper_point(0, "Not Painting Anymore");
|
||||
#endif /* USE_SPEEDSHOP_CALIPERS */
|
||||
g_timer_stop(timer);
|
||||
printf("painting took %f:\n", g_timer_elapsed(timer, NULL));
|
||||
g_timer_destroy(timer);
|
||||
#endif /* TIMED_BRUSH */
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Tool *
|
||||
tools_new_pixmapbrush ()
|
||||
{
|
||||
Tool * tool;
|
||||
PaintCore * private;
|
||||
|
||||
if (! pixmap_paint_options)
|
||||
{
|
||||
pixmap_paint_options = pixmapbrush_options_new ();
|
||||
tools_register (PIXMAPBRUSH, (ToolOptions *) pixmap_paint_options);
|
||||
|
||||
pixmapbrush_options_reset();
|
||||
}
|
||||
tool = paint_core_new (PIXMAPBRUSH);
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = pixmap_paint_func;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tools_free_pixmapbrush (Tool *tool)
|
||||
{
|
||||
paint_core_free (tool);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pixmapbrush_motion (PaintCore *paint_core,
|
||||
GimpDrawable *drawable,
|
||||
double fade_out,
|
||||
double gradient_length,
|
||||
gboolean incremental)
|
||||
{
|
||||
GImage *gimage;
|
||||
GimpBrushPixmap *brush = 0;
|
||||
TempBuf * pixmap_data;
|
||||
TempBuf * area;
|
||||
double position;
|
||||
unsigned char *d;
|
||||
int y;
|
||||
unsigned char col[MAX_CHANNELS];
|
||||
void * pr;
|
||||
PixelRegion destPR;
|
||||
pr = NULL;
|
||||
|
||||
/* FIXME: this code doesnt work quite right at the far top and
|
||||
and left sides. need to handle those cases better */
|
||||
|
||||
brush = GIMP_BRUSH_PIXMAP(paint_core->brush);
|
||||
pixmap_data = gimp_brush_pixmap_get_pixmap(brush);
|
||||
position = 0.0;
|
||||
|
||||
/* We always need a destination image */
|
||||
if (! (gimage = drawable_gimage (drawable)))
|
||||
return;
|
||||
|
||||
|
||||
/* Get a region which can be used to p\\aint to */
|
||||
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
|
||||
return;
|
||||
|
||||
/* stolen from clone.c */
|
||||
/* this should be a similar thing to want to do, right? */
|
||||
/* if I understand correctly, this just initilizes the dest
|
||||
pixel region to the same bitdepth, height and width of
|
||||
the drawable (area), then copies the apprriate data
|
||||
from area to destPR.data */
|
||||
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);
|
||||
|
||||
/* register this pixel region */
|
||||
pr = pixel_regions_register (1, &destPR);
|
||||
|
||||
for (; pr != NULL; pr = pixel_regions_process (pr))
|
||||
{
|
||||
d = destPR.data;
|
||||
for(y = 0; y < destPR.h; y++)
|
||||
{
|
||||
/* printf("y: %i destPR.h: %i\n", y, destPR.h); */
|
||||
paint_line_pixmap_mask(gimage, drawable, brush,
|
||||
d, area->x, area->y, y,
|
||||
destPR.bytes, destPR.w);
|
||||
|
||||
d += destPR.rowstride;
|
||||
}
|
||||
}
|
||||
|
||||
/* this will eventually get replaced with the code to merge
|
||||
the brush mask and the pixmap data into one temp_buf */
|
||||
/* color the pixels */
|
||||
|
||||
/* printf("temp_blend: %u grad_len: %f distance: %f \n",temp_blend, gradient_length, distance); */
|
||||
/* remove these once things are stable */
|
||||
/* printf("opacity: %i ", (int) (gimp_context_get_opacity (NULL) * 255)); */
|
||||
/* printf("r: %i g: %i b: %i a: %i\n", col[0], col[1], col[2], col[3]); */
|
||||
paint_core_paste_canvas (paint_core, drawable, 255,
|
||||
(int) (gimp_context_get_opacity (NULL) * 255),
|
||||
gimp_context_get_paint_mode (NULL), SOFT,
|
||||
INCREMENTAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void *
|
||||
pixmapbrush_non_gui_paint_func (PaintCore *paint_core,
|
||||
GimpDrawable *drawable,
|
||||
int state)
|
||||
{
|
||||
pixmapbrush_motion (paint_core, drawable, non_gui_fade_out,non_gui_gradient_length, non_gui_incremental);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
paint_line_pixmap_mask (GImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
GimpBrushPixmap *brush,
|
||||
unsigned char *d,
|
||||
int x,
|
||||
int y,
|
||||
int y2,
|
||||
int bytes,
|
||||
int width)
|
||||
{
|
||||
unsigned char *pat, *p;
|
||||
unsigned char *dp;
|
||||
int color, alpha;
|
||||
int i;
|
||||
unsigned char rgb[3];
|
||||
|
||||
/* point to the approriate scanline */
|
||||
/* use "pat" here because i'm c&p from pattern clone */
|
||||
pat = temp_buf_data (brush->pixmap_mask) +
|
||||
(y2 * brush->pixmap_mask->width * brush->pixmap_mask->bytes);
|
||||
|
||||
/* dest = d + (y * brush->pixmap_mask->width * brush->pixmap_mask->bytes); */
|
||||
color = RGB;
|
||||
|
||||
alpha = bytes -1;
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
p = pat + (i % brush->pixmap_mask->width) * brush->pixmap_mask->bytes;
|
||||
/* printf("x: %i y: %i y2: %i i: %i \n",x,y,y2,i); */
|
||||
/* printf("d->r: %i d->g: %i d->b: %i d->a: %i\n",(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */
|
||||
gimage_transform_color (dest, drawable, p, d, color);
|
||||
|
||||
d[3] = 255;
|
||||
d += bytes;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 __PIXMAPBRUSH_H__
|
||||
#define __PIXMAPBRUSH_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * pixmap_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
Tool * tools_new_pixmapbrush (void);
|
||||
void tools_free_pixmapbrush (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
/* extern ProcRecord pixmapbrush_proc; */
|
||||
/* extern ProcRecord pixmapbrush_extended_proc; */
|
||||
/* extern ProcRecord pixmapbrush_extended_gradient_proc; */
|
||||
#endif /* __PIXMAPBRUSH_H__ */
|
|
@ -570,7 +570,9 @@ paint_options_init (PaintOptions *options,
|
|||
_("Dodge or Burn Options") :
|
||||
((tool_type == SMUDGE) ?
|
||||
_("Smudge Options") :
|
||||
_("ERROR: Unknown Paint Type")))))))))))),
|
||||
((tool_type == PIXMAPBRUSH) ?
|
||||
_("Pixmap Brush Ootions") :
|
||||
_("ERROR: Unknown Paint Type"))))))))))))),
|
||||
reset_func);
|
||||
|
||||
/* initialize the paint options structure */
|
||||
|
@ -618,6 +620,7 @@ 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:"));
|
||||
|
|
16
app/tools.c
16
app/tools.c
|
@ -48,6 +48,7 @@
|
|||
#include "move.h"
|
||||
#include "paintbrush.h"
|
||||
#include "pencil.h"
|
||||
#include "pixmapbrush.h"
|
||||
#include "posterize.h"
|
||||
#include "rect_select.h"
|
||||
#include "session.h"
|
||||
|
@ -481,6 +482,21 @@ ToolInfo tool_info[] =
|
|||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
NULL,
|
||||
N_("Pixmap brush"),
|
||||
16,
|
||||
N_("/Tools/Pixmap Brush"),
|
||||
"P",
|
||||
(char **) paint_bits,
|
||||
N_("Paint fuzzy brush strokes"),
|
||||
"ContextHelp/paintbrush",
|
||||
PIXMAPBRUSH,
|
||||
tools_new_pixmapbrush,
|
||||
tools_free_pixmapbrush,
|
||||
NULL
|
||||
},
|
||||
|
||||
/* Non-toolbox tools */
|
||||
{
|
||||
NULL,
|
||||
|
|
|
@ -570,7 +570,9 @@ paint_options_init (PaintOptions *options,
|
|||
_("Dodge or Burn Options") :
|
||||
((tool_type == SMUDGE) ?
|
||||
_("Smudge Options") :
|
||||
_("ERROR: Unknown Paint Type")))))))))))),
|
||||
((tool_type == PIXMAPBRUSH) ?
|
||||
_("Pixmap Brush Ootions") :
|
||||
_("ERROR: Unknown Paint Type"))))))))))))),
|
||||
reset_func);
|
||||
|
||||
/* initialize the paint options structure */
|
||||
|
@ -618,6 +620,7 @@ 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:"));
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "move.h"
|
||||
#include "paintbrush.h"
|
||||
#include "pencil.h"
|
||||
#include "pixmapbrush.h"
|
||||
#include "posterize.h"
|
||||
#include "rect_select.h"
|
||||
#include "session.h"
|
||||
|
@ -481,6 +482,21 @@ ToolInfo tool_info[] =
|
|||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
NULL,
|
||||
N_("Pixmap brush"),
|
||||
16,
|
||||
N_("/Tools/Pixmap Brush"),
|
||||
"P",
|
||||
(char **) paint_bits,
|
||||
N_("Paint fuzzy brush strokes"),
|
||||
"ContextHelp/paintbrush",
|
||||
PIXMAPBRUSH,
|
||||
tools_new_pixmapbrush,
|
||||
tools_free_pixmapbrush,
|
||||
NULL
|
||||
},
|
||||
|
||||
/* Non-toolbox tools */
|
||||
{
|
||||
NULL,
|
||||
|
|
|
@ -64,7 +64,8 @@ typedef enum
|
|||
INK,
|
||||
DODGEBURN,
|
||||
SMUDGE,
|
||||
LAST_TOOLBOX_TOOL = SMUDGE,
|
||||
PIXMAPBRUSH,
|
||||
LAST_TOOLBOX_TOOL = PIXMAPBRUSH,
|
||||
|
||||
/* Non-toolbox tools */
|
||||
BY_COLOR_SELECT,
|
||||
|
|
Loading…
Reference in New Issue