2006-12-10 05:33:38 +08:00
|
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-07-09 13:31:06 +08:00
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-07-09 13:31:06 +08:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-07-09 13:31:06 +08:00
|
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1998-07-09 13:31:06 +08:00
|
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
|
#include <glib-object.h>
|
2011-04-06 04:11:27 +08:00
|
|
|
|
#include <cairo.h>
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
|
2003-10-16 20:24:58 +08:00
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2008-12-13 19:58:24 +08:00
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
2003-10-16 20:24:58 +08:00
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
|
#include "core-types.h"
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
#include "gimpbezierdesc.h"
|
1998-07-09 13:31:06 +08:00
|
|
|
|
#include "gimpbrush.h"
|
2011-04-05 03:11:39 +08:00
|
|
|
|
#include "gimpbrush-boundary.h"
|
2005-04-15 23:56:34 +08:00
|
|
|
|
#include "gimpbrush-load.h"
|
2009-02-01 19:08:22 +08:00
|
|
|
|
#include "gimpbrush-transform.h"
|
2011-04-06 04:11:27 +08:00
|
|
|
|
#include "gimpbrushcache.h"
|
2001-02-14 03:53:07 +08:00
|
|
|
|
#include "gimpbrushgenerated.h"
|
2001-11-23 07:46:13 +08:00
|
|
|
|
#include "gimpmarshal.h"
|
2008-12-13 19:58:24 +08:00
|
|
|
|
#include "gimptagged.h"
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
|
#include "gimp-intl.h"
|
1998-11-23 22:47:09 +08:00
|
|
|
|
|
2001-01-10 08:36:54 +08:00
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
SPACING_CHANGED,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2006-12-06 08:01:27 +08:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_SPACING
|
|
|
|
|
};
|
2001-06-30 03:25:03 +08:00
|
|
|
|
|
2006-12-06 08:01:27 +08:00
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static void gimp_brush_tagged_iface_init (GimpTaggedInterface *iface);
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
static void gimp_brush_finalize (GObject *object);
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static void gimp_brush_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gimp_brush_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
|
|
static gint64 gimp_brush_get_memsize (GimpObject *object,
|
|
|
|
|
gint64 *gui_size);
|
|
|
|
|
|
|
|
|
|
static gboolean gimp_brush_get_size (GimpViewable *viewable,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height);
|
|
|
|
|
static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height);
|
|
|
|
|
static gchar * gimp_brush_get_description (GimpViewable *viewable,
|
|
|
|
|
gchar **tooltip);
|
2011-04-06 04:11:27 +08:00
|
|
|
|
|
|
|
|
|
static void gimp_brush_dirty (GimpData *data);
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static const gchar * gimp_brush_get_extension (GimpData *data);
|
|
|
|
|
|
2011-04-12 19:59:04 +08:00
|
|
|
|
static void gimp_brush_real_begin_use (GimpBrush *brush);
|
|
|
|
|
static void gimp_brush_real_end_use (GimpBrush *brush);
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static GimpBrush * gimp_brush_real_select_brush (GimpBrush *brush,
|
2009-05-20 03:37:56 +08:00
|
|
|
|
const GimpCoords *last_coords,
|
|
|
|
|
const GimpCoords *current_coords);
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static gboolean gimp_brush_real_want_null_motion (GimpBrush *brush,
|
2009-05-20 03:37:56 +08:00
|
|
|
|
const GimpCoords *last_coords,
|
|
|
|
|
const GimpCoords *current_coords);
|
2008-12-13 19:58:24 +08:00
|
|
|
|
|
|
|
|
|
static gchar * gimp_brush_get_checksum (GimpTagged *tagged);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpBrush, gimp_brush, GIMP_TYPE_DATA,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
|
|
|
|
|
gimp_brush_tagged_iface_init))
|
2000-02-24 19:39:26 +08:00
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
|
#define parent_class gimp_brush_parent_class
|
2001-01-10 08:36:54 +08:00
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
|
static guint brush_signals[LAST_SIGNAL] = { 0 };
|
1998-07-09 13:31:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_brush_class_init (GimpBrushClass *klass)
|
|
|
|
|
{
|
2004-06-25 21:41:24 +08:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
|
GimpDataClass *data_class = GIMP_DATA_CLASS (klass);
|
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.
1999-08-26 08:54:30 +08:00
|
|
|
|
|
2003-07-10 20:13:21 +08:00
|
|
|
|
brush_signals[SPACING_CHANGED] =
|
2005-05-28 00:51:39 +08:00
|
|
|
|
g_signal_new ("spacing-changed",
|
2004-06-25 21:41:24 +08:00
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (GimpBrushClass, spacing_changed),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
object_class->finalize = gimp_brush_finalize;
|
2006-12-07 19:53:02 +08:00
|
|
|
|
object_class->get_property = gimp_brush_get_property;
|
|
|
|
|
object_class->set_property = gimp_brush_set_property;
|
2001-01-10 08:36:54 +08:00
|
|
|
|
|
2003-11-17 21:34:38 +08:00
|
|
|
|
gimp_object_class->get_memsize = gimp_brush_get_memsize;
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
2003-11-17 21:34:38 +08:00
|
|
|
|
viewable_class->default_stock_id = "gimp-tool-paintbrush";
|
2005-05-25 18:05:17 +08:00
|
|
|
|
viewable_class->get_size = gimp_brush_get_size;
|
2003-11-17 21:34:38 +08:00
|
|
|
|
viewable_class->get_new_preview = gimp_brush_get_new_preview;
|
|
|
|
|
viewable_class->get_description = gimp_brush_get_description;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
data_class->dirty = gimp_brush_dirty;
|
2003-11-17 21:34:38 +08:00
|
|
|
|
data_class->get_extension = gimp_brush_get_extension;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2011-04-12 19:59:04 +08:00
|
|
|
|
klass->begin_use = gimp_brush_real_begin_use;
|
|
|
|
|
klass->end_use = gimp_brush_real_end_use;
|
2003-11-17 21:34:38 +08:00
|
|
|
|
klass->select_brush = gimp_brush_real_select_brush;
|
|
|
|
|
klass->want_null_motion = gimp_brush_real_want_null_motion;
|
2009-02-01 19:08:22 +08:00
|
|
|
|
klass->transform_size = gimp_brush_real_transform_size;
|
|
|
|
|
klass->transform_mask = gimp_brush_real_transform_mask;
|
|
|
|
|
klass->transform_pixmap = gimp_brush_real_transform_pixmap;
|
2011-04-05 03:11:39 +08:00
|
|
|
|
klass->transform_boundary = gimp_brush_real_transform_boundary;
|
2003-11-17 21:34:38 +08:00
|
|
|
|
klass->spacing_changed = NULL;
|
2006-12-06 08:01:27 +08:00
|
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_SPACING,
|
2009-04-27 17:01:11 +08:00
|
|
|
|
g_param_spec_double ("spacing", NULL,
|
|
|
|
|
_("Brush Spacing"),
|
2006-12-06 08:01:27 +08:00
|
|
|
|
1.0, 5000.0, 20.0,
|
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT));
|
1998-07-09 13:31:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_brush_tagged_iface_init (GimpTaggedInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_checksum = gimp_brush_get_checksum;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
|
static void
|
2000-02-24 09:52:31 +08:00
|
|
|
|
gimp_brush_init (GimpBrush *brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
|
brush->mask = NULL;
|
|
|
|
|
brush->pixmap = NULL;
|
|
|
|
|
|
|
|
|
|
brush->spacing = 20;
|
|
|
|
|
brush->x_axis.x = 15.0;
|
|
|
|
|
brush->x_axis.y = 0.0;
|
|
|
|
|
brush->y_axis.x = 0.0;
|
|
|
|
|
brush->y_axis.y = 15.0;
|
1998-07-09 13:31:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_brush_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (object);
|
|
|
|
|
|
|
|
|
|
if (brush->mask)
|
|
|
|
|
{
|
|
|
|
|
temp_buf_free (brush->mask);
|
|
|
|
|
brush->mask = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (brush->pixmap)
|
|
|
|
|
{
|
|
|
|
|
temp_buf_free (brush->pixmap);
|
|
|
|
|
brush->pixmap = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (brush->mask_cache)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (brush->mask_cache);
|
|
|
|
|
brush->mask_cache = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (brush->pixmap_cache)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (brush->pixmap_cache);
|
|
|
|
|
brush->pixmap_cache = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (brush->boundary_cache)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (brush->boundary_cache);
|
|
|
|
|
brush->boundary_cache = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-06 08:01:27 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_brush_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_SPACING:
|
|
|
|
|
gimp_brush_set_spacing (brush, g_value_get_double (value));
|
|
|
|
|
break;
|
2007-04-01 21:38:22 +08:00
|
|
|
|
|
2006-12-06 08:01:27 +08:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_brush_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_SPACING:
|
|
|
|
|
g_value_set_double (value, brush->spacing);
|
|
|
|
|
break;
|
2007-04-01 21:38:22 +08:00
|
|
|
|
|
2006-12-06 08:01:27 +08:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
|
static gint64
|
2003-08-25 18:49:33 +08:00
|
|
|
|
gimp_brush_get_memsize (GimpObject *object,
|
2003-11-17 01:51:36 +08:00
|
|
|
|
gint64 *gui_size)
|
2002-01-31 00:14:26 +08:00
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (object);
|
2003-11-17 01:51:36 +08:00
|
|
|
|
gint64 memsize = 0;
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
2007-11-17 02:19:30 +08:00
|
|
|
|
memsize += temp_buf_get_memsize (brush->mask);
|
|
|
|
|
memsize += temp_buf_get_memsize (brush->pixmap);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
|
gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-27 21:59:41 +08:00
|
|
|
|
static gboolean
|
2005-05-25 18:05:17 +08:00
|
|
|
|
gimp_brush_get_size (GimpViewable *viewable,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2003-02-27 21:59:41 +08:00
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (viewable);
|
2003-02-27 21:59:41 +08:00
|
|
|
|
|
2005-05-25 18:05:17 +08:00
|
|
|
|
*width = brush->mask->width;
|
|
|
|
|
*height = brush->mask->height;
|
2003-02-27 21:59:41 +08:00
|
|
|
|
|
2005-05-25 18:05:17 +08:00
|
|
|
|
return TRUE;
|
2003-02-27 21:59:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
|
static TempBuf *
|
2001-02-07 08:06:58 +08:00
|
|
|
|
gimp_brush_get_new_preview (GimpViewable *viewable,
|
2006-08-30 05:44:51 +08:00
|
|
|
|
GimpContext *context,
|
2004-06-25 21:41:24 +08:00
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
1998-07-09 13:31:06 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (viewable);
|
|
|
|
|
const TempBuf *mask_buf = NULL;
|
|
|
|
|
gboolean free_mask = FALSE;
|
|
|
|
|
const TempBuf *pixmap_buf = NULL;
|
|
|
|
|
TempBuf *return_buf = NULL;
|
|
|
|
|
gint mask_width;
|
|
|
|
|
gint mask_height;
|
|
|
|
|
guchar *mask;
|
|
|
|
|
guchar *buf;
|
|
|
|
|
gint x, y;
|
|
|
|
|
gboolean scaled = FALSE;
|
2000-02-24 09:52:31 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
mask_buf = brush->mask;
|
|
|
|
|
pixmap_buf = brush->pixmap;
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
mask_width = mask_buf->width;
|
|
|
|
|
mask_height = mask_buf->height;
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
if (mask_width > width || mask_height > height)
|
2001-02-06 23:57:07 +08:00
|
|
|
|
{
|
2007-04-01 21:38:22 +08:00
|
|
|
|
gdouble ratio_x = (gdouble) width / (gdouble) mask_width;
|
|
|
|
|
gdouble ratio_y = (gdouble) height / (gdouble) mask_height;
|
|
|
|
|
gdouble scale = MIN (ratio_x, ratio_y);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
if (scale != 1.0)
|
|
|
|
|
{
|
2011-04-12 15:06:22 +08:00
|
|
|
|
gimp_brush_begin_use (brush);
|
2011-04-06 04:11:27 +08:00
|
|
|
|
|
|
|
|
|
mask_buf = gimp_brush_transform_mask (brush, scale,
|
|
|
|
|
0.0, 0.0, 1.0);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
if (! mask_buf)
|
2011-04-06 04:11:27 +08:00
|
|
|
|
{
|
2012-04-08 05:46:43 +08:00
|
|
|
|
mask_buf = temp_buf_new (1, 1, 1);
|
|
|
|
|
temp_buf_data_clear ((TempBuf *) mask_buf);
|
2011-04-06 04:11:27 +08:00
|
|
|
|
free_mask = TRUE;
|
|
|
|
|
}
|
2004-12-27 02:18:17 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
if (pixmap_buf)
|
2011-04-06 04:11:27 +08:00
|
|
|
|
pixmap_buf = gimp_brush_transform_pixmap (brush, scale,
|
|
|
|
|
0.0, 0.0, 1.0);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
mask_width = mask_buf->width;
|
|
|
|
|
mask_height = mask_buf->height;
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-05-22 15:20:23 +08:00
|
|
|
|
scaled = TRUE;
|
2007-04-01 21:38:22 +08:00
|
|
|
|
}
|
2001-02-06 23:57:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-08 05:46:43 +08:00
|
|
|
|
return_buf = temp_buf_new (mask_width, mask_height, 4);
|
|
|
|
|
temp_buf_data_clear (return_buf);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2008-12-13 18:35:53 +08:00
|
|
|
|
mask = temp_buf_get_data (mask_buf);
|
|
|
|
|
buf = temp_buf_get_data (return_buf);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
|
|
|
|
if (pixmap_buf)
|
|
|
|
|
{
|
2008-12-13 18:35:53 +08:00
|
|
|
|
guchar *pixmap = temp_buf_get_data (pixmap_buf);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2007-04-01 21:38:22 +08:00
|
|
|
|
for (y = 0; y < mask_height; y++)
|
2001-02-06 23:57:07 +08:00
|
|
|
|
{
|
2007-04-01 21:38:22 +08:00
|
|
|
|
for (x = 0; x < mask_width ; x++)
|
2001-02-06 23:57:07 +08:00
|
|
|
|
{
|
2003-02-27 00:15:50 +08:00
|
|
|
|
*buf++ = *pixmap++;
|
|
|
|
|
*buf++ = *pixmap++;
|
|
|
|
|
*buf++ = *pixmap++;
|
|
|
|
|
*buf++ = *mask++;
|
2001-02-06 23:57:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-04-01 21:38:22 +08:00
|
|
|
|
for (y = 0; y < mask_height; y++)
|
2001-02-06 23:57:07 +08:00
|
|
|
|
{
|
2007-04-01 21:38:22 +08:00
|
|
|
|
for (x = 0; x < mask_width ; x++)
|
2001-02-06 23:57:07 +08:00
|
|
|
|
{
|
2003-02-27 00:15:50 +08:00
|
|
|
|
*buf++ = 0;
|
|
|
|
|
*buf++ = 0;
|
|
|
|
|
*buf++ = 0;
|
|
|
|
|
*buf++ = *mask++;
|
2001-02-06 23:57:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-22 15:20:23 +08:00
|
|
|
|
if (scaled)
|
2001-02-06 23:57:07 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
if (free_mask)
|
|
|
|
|
temp_buf_free ((TempBuf *) mask_buf);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
gimp_brush_end_use (brush);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
}
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
2001-02-06 23:57:07 +08:00
|
|
|
|
return return_buf;
|
1998-07-09 13:31:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-09 00:01:01 +08:00
|
|
|
|
static gchar *
|
|
|
|
|
gimp_brush_get_description (GimpViewable *viewable,
|
|
|
|
|
gchar **tooltip)
|
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (viewable);
|
2003-04-09 00:01:01 +08:00
|
|
|
|
|
2006-02-28 20:15:51 +08:00
|
|
|
|
return g_strdup_printf ("%s (%d × %d)",
|
2009-08-29 18:40:40 +08:00
|
|
|
|
gimp_object_get_name (brush),
|
2003-04-09 00:01:01 +08:00
|
|
|
|
brush->mask->width,
|
|
|
|
|
brush->mask->height);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_brush_dirty (GimpData *data)
|
|
|
|
|
{
|
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (data);
|
|
|
|
|
|
|
|
|
|
if (brush->mask_cache)
|
|
|
|
|
gimp_brush_cache_clear (brush->mask_cache);
|
|
|
|
|
|
|
|
|
|
if (brush->pixmap_cache)
|
|
|
|
|
gimp_brush_cache_clear (brush->pixmap_cache);
|
|
|
|
|
|
|
|
|
|
if (brush->boundary_cache)
|
|
|
|
|
gimp_brush_cache_clear (brush->boundary_cache);
|
|
|
|
|
|
|
|
|
|
GIMP_DATA_CLASS (parent_class)->dirty (data);
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-12 18:35:35 +08:00
|
|
|
|
static const gchar *
|
2001-02-14 03:53:07 +08:00
|
|
|
|
gimp_brush_get_extension (GimpData *data)
|
|
|
|
|
{
|
|
|
|
|
return GIMP_BRUSH_FILE_EXTENSION;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 19:59:04 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_brush_real_begin_use (GimpBrush *brush)
|
|
|
|
|
{
|
|
|
|
|
brush->mask_cache =
|
|
|
|
|
gimp_brush_cache_new ((GDestroyNotify) temp_buf_free, 'M', 'm');
|
|
|
|
|
|
|
|
|
|
brush->pixmap_cache =
|
|
|
|
|
gimp_brush_cache_new ((GDestroyNotify) temp_buf_free, 'P', 'p');
|
|
|
|
|
|
|
|
|
|
brush->boundary_cache =
|
|
|
|
|
gimp_brush_cache_new ((GDestroyNotify) gimp_bezier_desc_free, 'B', 'b');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_brush_real_end_use (GimpBrush *brush)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (brush->mask_cache);
|
|
|
|
|
brush->mask_cache = NULL;
|
|
|
|
|
|
|
|
|
|
g_object_unref (brush->pixmap_cache);
|
|
|
|
|
brush->pixmap_cache = NULL;
|
|
|
|
|
|
|
|
|
|
g_object_unref (brush->boundary_cache);
|
|
|
|
|
brush->boundary_cache = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-09 22:54:49 +08:00
|
|
|
|
static GimpBrush *
|
2009-05-20 03:37:56 +08:00
|
|
|
|
gimp_brush_real_select_brush (GimpBrush *brush,
|
|
|
|
|
const GimpCoords *last_coords,
|
|
|
|
|
const GimpCoords *current_coords)
|
2006-11-09 22:54:49 +08:00
|
|
|
|
{
|
|
|
|
|
return brush;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2009-05-20 03:37:56 +08:00
|
|
|
|
gimp_brush_real_want_null_motion (GimpBrush *brush,
|
|
|
|
|
const GimpCoords *last_coords,
|
|
|
|
|
const GimpCoords *current_coords)
|
2006-11-09 22:54:49 +08:00
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static gchar *
|
|
|
|
|
gimp_brush_get_checksum (GimpTagged *tagged)
|
|
|
|
|
{
|
|
|
|
|
GimpBrush *brush = GIMP_BRUSH (tagged);
|
|
|
|
|
gchar *checksum_string = NULL;
|
|
|
|
|
|
|
|
|
|
if (brush->mask)
|
|
|
|
|
{
|
|
|
|
|
GChecksum *checksum = g_checksum_new (G_CHECKSUM_MD5);
|
|
|
|
|
|
|
|
|
|
g_checksum_update (checksum, temp_buf_get_data (brush->mask), temp_buf_get_data_size (brush->mask));
|
|
|
|
|
if (brush->pixmap)
|
|
|
|
|
g_checksum_update (checksum, temp_buf_get_data (brush->pixmap), temp_buf_get_data_size (brush->pixmap));
|
|
|
|
|
g_checksum_update (checksum, (const guchar *) &brush->spacing, sizeof (brush->spacing));
|
|
|
|
|
g_checksum_update (checksum, (const guchar *) &brush->x_axis, sizeof (brush->x_axis));
|
|
|
|
|
g_checksum_update (checksum, (const guchar *) &brush->y_axis, sizeof (brush->y_axis));
|
|
|
|
|
|
|
|
|
|
checksum_string = g_strdup (g_checksum_get_string (checksum));
|
|
|
|
|
|
|
|
|
|
g_checksum_free (checksum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return checksum_string;
|
|
|
|
|
}
|
2007-03-14 18:23:18 +08:00
|
|
|
|
|
2006-11-09 22:54:49 +08:00
|
|
|
|
/* public functions */
|
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
|
GimpData *
|
2010-04-11 01:55:42 +08:00
|
|
|
|
gimp_brush_new (GimpContext *context,
|
|
|
|
|
const gchar *name)
|
2001-02-14 03:53:07 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
2004-08-01 11:06:58 +08:00
|
|
|
|
return gimp_brush_generated_new (name,
|
|
|
|
|
GIMP_BRUSH_GENERATED_CIRCLE,
|
2005-06-08 19:27:31 +08:00
|
|
|
|
5.0, 2, 0.5, 1.0, 0.0);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
|
GimpData *
|
2010-04-05 19:24:54 +08:00
|
|
|
|
gimp_brush_get_standard (GimpContext *context)
|
2001-02-14 03:53:07 +08:00
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
|
static GimpData *standard_brush = NULL;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
|
|
|
|
if (! standard_brush)
|
|
|
|
|
{
|
2010-04-11 01:55:42 +08:00
|
|
|
|
standard_brush = gimp_brush_new (context, "Standard");
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2009-11-01 01:48:38 +08:00
|
|
|
|
gimp_data_clean (standard_brush);
|
|
|
|
|
gimp_data_make_internal (standard_brush, "gimp-brush-standard");
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2010-06-24 18:46:45 +08:00
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (standard_brush),
|
|
|
|
|
(gpointer *) &standard_brush);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
|
return standard_brush;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 19:59:04 +08:00
|
|
|
|
void
|
|
|
|
|
gimp_brush_begin_use (GimpBrush *brush)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
|
|
|
|
|
|
|
|
|
brush->use_count++;
|
|
|
|
|
|
|
|
|
|
if (brush->use_count == 1)
|
|
|
|
|
GIMP_BRUSH_GET_CLASS (brush)->begin_use (brush);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gimp_brush_end_use (GimpBrush *brush)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
|
|
|
|
g_return_if_fail (brush->use_count > 0);
|
|
|
|
|
|
|
|
|
|
brush->use_count--;
|
|
|
|
|
|
|
|
|
|
if (brush->use_count == 0)
|
|
|
|
|
GIMP_BRUSH_GET_CLASS (brush)->end_use (brush);
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-02 06:59:48 +08:00
|
|
|
|
GimpBrush *
|
2009-05-20 03:37:56 +08:00
|
|
|
|
gimp_brush_select_brush (GimpBrush *brush,
|
|
|
|
|
const GimpCoords *last_coords,
|
|
|
|
|
const GimpCoords *current_coords)
|
2001-12-02 06:59:48 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
|
|
|
|
g_return_val_if_fail (last_coords != NULL, NULL);
|
2009-05-20 03:37:56 +08:00
|
|
|
|
g_return_val_if_fail (current_coords != NULL, NULL);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
|
|
|
|
|
return GIMP_BRUSH_GET_CLASS (brush)->select_brush (brush,
|
|
|
|
|
last_coords,
|
2009-05-20 03:37:56 +08:00
|
|
|
|
current_coords);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
2009-05-20 03:37:56 +08:00
|
|
|
|
gimp_brush_want_null_motion (GimpBrush *brush,
|
|
|
|
|
const GimpCoords *last_coords,
|
|
|
|
|
const GimpCoords *current_coords)
|
2001-12-02 06:59:48 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), FALSE);
|
|
|
|
|
g_return_val_if_fail (last_coords != NULL, FALSE);
|
2009-05-20 03:37:56 +08:00
|
|
|
|
g_return_val_if_fail (current_coords != NULL, FALSE);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
|
|
|
|
|
return GIMP_BRUSH_GET_CLASS (brush)->want_null_motion (brush,
|
|
|
|
|
last_coords,
|
2009-05-20 03:37:56 +08:00
|
|
|
|
current_coords);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-14 18:23:18 +08:00
|
|
|
|
void
|
2009-02-01 19:08:22 +08:00
|
|
|
|
gimp_brush_transform_size (GimpBrush *brush,
|
2009-04-26 01:53:09 +08:00
|
|
|
|
gdouble scale,
|
|
|
|
|
gdouble aspect_ratio,
|
2009-02-06 05:47:57 +08:00
|
|
|
|
gdouble angle,
|
2009-02-01 19:08:22 +08:00
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2007-03-14 18:23:18 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
2009-04-26 01:53:09 +08:00
|
|
|
|
g_return_if_fail (scale > 0.0);
|
2007-03-14 18:23:18 +08:00
|
|
|
|
g_return_if_fail (width != NULL);
|
|
|
|
|
g_return_if_fail (height != NULL);
|
|
|
|
|
|
2011-04-05 00:57:48 +08:00
|
|
|
|
if (scale == 1.0 &&
|
|
|
|
|
aspect_ratio == 0.0 &&
|
|
|
|
|
((angle == 0.0) || (angle == 0.5) || (angle == 1.0)))
|
2007-03-19 03:48:36 +08:00
|
|
|
|
{
|
|
|
|
|
*width = brush->mask->width;
|
|
|
|
|
*height = brush->mask->height;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-05 00:57:48 +08:00
|
|
|
|
GIMP_BRUSH_GET_CLASS (brush)->transform_size (brush,
|
|
|
|
|
scale, aspect_ratio, angle,
|
|
|
|
|
width, height);
|
2007-03-14 18:23:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
const TempBuf *
|
2009-02-01 19:08:22 +08:00
|
|
|
|
gimp_brush_transform_mask (GimpBrush *brush,
|
2009-04-26 01:53:09 +08:00
|
|
|
|
gdouble scale,
|
|
|
|
|
gdouble aspect_ratio,
|
2010-01-01 21:41:07 +08:00
|
|
|
|
gdouble angle,
|
|
|
|
|
gdouble hardness)
|
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.
1999-08-26 08:54:30 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
const TempBuf *mask;
|
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
|
|
|
|
|
2006-11-09 22:54:49 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
2009-04-26 01:53:09 +08:00
|
|
|
|
g_return_val_if_fail (scale > 0.0, NULL);
|
2006-11-09 22:54:49 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
gimp_brush_transform_size (brush,
|
|
|
|
|
scale, aspect_ratio, angle,
|
|
|
|
|
&width, &height);
|
|
|
|
|
|
|
|
|
|
mask = gimp_brush_cache_get (brush->mask_cache,
|
|
|
|
|
width, height,
|
|
|
|
|
scale, aspect_ratio, angle, hardness);
|
|
|
|
|
|
|
|
|
|
if (! mask)
|
2011-04-05 00:57:48 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
if (scale == 1.0 &&
|
|
|
|
|
aspect_ratio == 0.0 &&
|
|
|
|
|
angle == 0.0 &&
|
|
|
|
|
hardness == 1.0)
|
|
|
|
|
{
|
|
|
|
|
mask = temp_buf_copy (brush->mask, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mask = GIMP_BRUSH_GET_CLASS (brush)->transform_mask (brush,
|
|
|
|
|
scale,
|
|
|
|
|
aspect_ratio,
|
|
|
|
|
angle,
|
|
|
|
|
hardness);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_brush_cache_add (brush->mask_cache,
|
|
|
|
|
(gpointer) mask,
|
|
|
|
|
width, height,
|
|
|
|
|
scale, aspect_ratio, angle, hardness);
|
2011-04-05 00:57:48 +08:00
|
|
|
|
}
|
2007-04-01 21:38:22 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
return mask;
|
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.
1999-08-26 08:54:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
const TempBuf *
|
2009-02-01 19:08:22 +08:00
|
|
|
|
gimp_brush_transform_pixmap (GimpBrush *brush,
|
2009-04-26 01:53:09 +08:00
|
|
|
|
gdouble scale,
|
|
|
|
|
gdouble aspect_ratio,
|
2010-01-01 21:41:07 +08:00
|
|
|
|
gdouble angle,
|
|
|
|
|
gdouble hardness)
|
1999-08-31 05:24:13 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
const TempBuf *pixmap;
|
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
|
|
|
|
|
2006-11-09 22:54:49 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
|
|
|
|
g_return_val_if_fail (brush->pixmap != NULL, NULL);
|
2009-04-26 01:53:09 +08:00
|
|
|
|
g_return_val_if_fail (scale > 0.0, NULL);
|
2006-11-09 22:54:49 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
gimp_brush_transform_size (brush,
|
|
|
|
|
scale, aspect_ratio, angle,
|
|
|
|
|
&width, &height);
|
|
|
|
|
|
|
|
|
|
pixmap = gimp_brush_cache_get (brush->pixmap_cache,
|
|
|
|
|
width, height,
|
|
|
|
|
scale, aspect_ratio, angle, hardness);
|
|
|
|
|
|
|
|
|
|
if (! pixmap)
|
2011-04-05 00:57:48 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
if (scale == 1.0 &&
|
|
|
|
|
aspect_ratio == 0.0 &&
|
|
|
|
|
angle == 0.0 &&
|
|
|
|
|
hardness == 1.0)
|
|
|
|
|
{
|
|
|
|
|
pixmap = temp_buf_copy (brush->pixmap, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pixmap = GIMP_BRUSH_GET_CLASS (brush)->transform_pixmap (brush,
|
|
|
|
|
scale,
|
|
|
|
|
aspect_ratio,
|
|
|
|
|
angle,
|
|
|
|
|
hardness);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_brush_cache_add (brush->pixmap_cache,
|
|
|
|
|
(gpointer) pixmap,
|
|
|
|
|
width, height,
|
|
|
|
|
scale, aspect_ratio, angle, hardness);
|
2011-04-05 00:57:48 +08:00
|
|
|
|
}
|
2007-04-01 21:38:22 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
return pixmap;
|
1999-08-31 05:24:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
const GimpBezierDesc *
|
2011-04-05 01:21:25 +08:00
|
|
|
|
gimp_brush_transform_boundary (GimpBrush *brush,
|
|
|
|
|
gdouble scale,
|
|
|
|
|
gdouble aspect_ratio,
|
|
|
|
|
gdouble angle,
|
2011-04-05 03:11:39 +08:00
|
|
|
|
gdouble hardness,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2011-04-05 01:21:25 +08:00
|
|
|
|
{
|
2011-04-06 04:11:27 +08:00
|
|
|
|
const GimpBezierDesc *boundary;
|
|
|
|
|
|
2011-04-05 01:21:25 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
2011-04-05 03:11:39 +08:00
|
|
|
|
g_return_val_if_fail (scale > 0.0, NULL);
|
|
|
|
|
g_return_val_if_fail (width != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (height != NULL, NULL);
|
2011-04-05 01:21:25 +08:00
|
|
|
|
|
2011-04-06 04:11:27 +08:00
|
|
|
|
gimp_brush_transform_size (brush,
|
|
|
|
|
scale, aspect_ratio, angle,
|
|
|
|
|
width, height);
|
|
|
|
|
|
|
|
|
|
boundary = gimp_brush_cache_get (brush->boundary_cache,
|
|
|
|
|
*width, *height,
|
|
|
|
|
scale, aspect_ratio, angle, hardness);
|
|
|
|
|
|
|
|
|
|
if (! boundary)
|
|
|
|
|
{
|
|
|
|
|
boundary = GIMP_BRUSH_GET_CLASS (brush)->transform_boundary (brush,
|
|
|
|
|
scale,
|
|
|
|
|
aspect_ratio,
|
|
|
|
|
angle,
|
|
|
|
|
hardness,
|
|
|
|
|
width,
|
|
|
|
|
height);
|
|
|
|
|
|
2011-04-09 03:22:55 +08:00
|
|
|
|
/* while the brush mask is always at least 1x1 pixels, its
|
|
|
|
|
* outline can correctly be NULL
|
|
|
|
|
*
|
|
|
|
|
* FIXME: make the cache handle NULL things when it is
|
|
|
|
|
* properly implemented
|
|
|
|
|
*/
|
|
|
|
|
if (boundary)
|
|
|
|
|
gimp_brush_cache_add (brush->boundary_cache,
|
|
|
|
|
(gpointer) boundary,
|
|
|
|
|
*width, *height,
|
|
|
|
|
scale, aspect_ratio, angle, hardness);
|
2011-04-06 04:11:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return boundary;
|
2011-04-05 01:21:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
|
TempBuf *
|
2001-01-14 11:55:56 +08:00
|
|
|
|
gimp_brush_get_mask (const GimpBrush *brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
|
g_return_val_if_fail (brush != NULL, NULL);
|
2000-02-24 09:52:31 +08:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
|
return brush->mask;
|
|
|
|
|
}
|
|
|
|
|
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
TempBuf *
|
2001-01-14 11:55:56 +08:00
|
|
|
|
gimp_brush_get_pixmap (const GimpBrush *brush)
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (brush != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
|
|
|
|
|
|
|
|
|
return brush->pixmap;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-24 09:52:31 +08:00
|
|
|
|
gint
|
2001-01-14 11:55:56 +08:00
|
|
|
|
gimp_brush_get_spacing (const GimpBrush *brush)
|
1999-04-22 22:34:00 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
|
|
|
|
|
|
|
|
|
|
return brush->spacing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gimp_brush_set_spacing (GimpBrush *brush,
|
2004-08-01 11:06:58 +08:00
|
|
|
|
gint spacing)
|
1999-04-22 22:34:00 +08:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
|
if (brush->spacing != spacing)
|
|
|
|
|
{
|
|
|
|
|
brush->spacing = spacing;
|
|
|
|
|
|
2011-04-06 01:09:56 +08:00
|
|
|
|
g_signal_emit (brush, brush_signals[SPACING_CHANGED], 0);
|
2006-12-06 08:01:27 +08:00
|
|
|
|
g_object_notify (G_OBJECT (brush), "spacing");
|
2001-06-30 03:25:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|