2006-12-10 05:33:38 +08:00
|
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-02-05 01:34:30 +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
|
2001-02-05 01:34:30 +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
|
2001-02-05 01:34:30 +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/>.
|
2001-02-05 01:34:30 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2012-03-18 04:59:10 +08:00
|
|
|
|
#include <gegl.h>
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
2003-10-16 20:24:58 +08:00
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
|
#include "core-types.h"
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
|
|
|
|
#include "gimppattern.h"
|
2006-10-03 19:37:37 +08:00
|
|
|
|
#include "gimppattern-load.h"
|
2008-12-13 19:58:24 +08:00
|
|
|
|
#include "gimptagged.h"
|
2012-04-09 06:59:20 +08:00
|
|
|
|
#include "gimptempbuf.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
|
#include "gimp-intl.h"
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static void gimp_pattern_tagged_iface_init (GimpTaggedInterface *iface);
|
|
|
|
|
static void gimp_pattern_finalize (GObject *object);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static gint64 gimp_pattern_get_memsize (GimpObject *object,
|
|
|
|
|
gint64 *gui_size);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static gboolean gimp_pattern_get_size (GimpViewable *viewable,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height);
|
2012-04-09 02:25:49 +08:00
|
|
|
|
static GimpTempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable,
|
2008-12-13 19:58:24 +08:00
|
|
|
|
GimpContext *context,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height);
|
|
|
|
|
static gchar * gimp_pattern_get_description (GimpViewable *viewable,
|
|
|
|
|
gchar **tooltip);
|
2008-09-12 18:35:35 +08:00
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static const gchar * gimp_pattern_get_extension (GimpData *data);
|
|
|
|
|
static GimpData * gimp_pattern_duplicate (GimpData *data);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static gchar * gimp_pattern_get_checksum (GimpTagged *tagged);
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpPattern, gimp_pattern, GIMP_TYPE_DATA,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
|
|
|
|
|
gimp_pattern_tagged_iface_init))
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
|
#define parent_class gimp_pattern_parent_class
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_pattern_class_init (GimpPatternClass *klass)
|
|
|
|
|
{
|
2005-07-24 06:22:45 +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);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
2003-11-17 21:34:38 +08:00
|
|
|
|
object_class->finalize = gimp_pattern_finalize;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
2003-11-17 21:34:38 +08:00
|
|
|
|
gimp_object_class->get_memsize = gimp_pattern_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-bucket-fill";
|
2005-05-25 18:05:17 +08:00
|
|
|
|
viewable_class->get_size = gimp_pattern_get_size;
|
2003-11-17 21:34:38 +08:00
|
|
|
|
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
|
|
|
|
|
viewable_class->get_description = gimp_pattern_get_description;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2003-11-17 21:34:38 +08:00
|
|
|
|
data_class->get_extension = gimp_pattern_get_extension;
|
|
|
|
|
data_class->duplicate = gimp_pattern_duplicate;
|
2001-02-05 01:34:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_pattern_tagged_iface_init (GimpTaggedInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_checksum = gimp_pattern_get_checksum;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
|
static void
|
|
|
|
|
gimp_pattern_init (GimpPattern *pattern)
|
|
|
|
|
{
|
2001-02-11 09:39:24 +08:00
|
|
|
|
pattern->mask = NULL;
|
2001-02-05 01:34:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2001-08-11 22:39:19 +08:00
|
|
|
|
gimp_pattern_finalize (GObject *object)
|
2001-02-05 01:34:30 +08:00
|
|
|
|
{
|
2003-11-17 01:51:36 +08:00
|
|
|
|
GimpPattern *pattern = GIMP_PATTERN (object);
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
|
|
|
|
if (pattern->mask)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
{
|
2012-04-09 06:16:46 +08:00
|
|
|
|
gimp_temp_buf_unref (pattern->mask);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
pattern->mask = NULL;
|
|
|
|
|
}
|
2001-02-05 01:34:30 +08:00
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-05 01:34:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
|
static gint64
|
2003-08-25 18:49:33 +08:00
|
|
|
|
gimp_pattern_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
|
|
|
|
GimpPattern *pattern = GIMP_PATTERN (object);
|
2003-11-17 01:51:36 +08:00
|
|
|
|
gint64 memsize = 0;
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
2012-04-09 05:56:52 +08:00
|
|
|
|
memsize += gimp_temp_buf_get_memsize (pattern->mask);
|
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_pattern_get_size (GimpViewable *viewable,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2003-02-27 21:59:41 +08:00
|
|
|
|
{
|
2003-11-17 01:51:36 +08:00
|
|
|
|
GimpPattern *pattern = GIMP_PATTERN (viewable);
|
2003-02-27 21:59:41 +08:00
|
|
|
|
|
2012-04-23 15:40:56 +08:00
|
|
|
|
*width = gimp_temp_buf_get_width (pattern->mask);
|
|
|
|
|
*height = gimp_temp_buf_get_height (pattern->mask);
|
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
|
|
|
|
}
|
|
|
|
|
|
2012-04-09 02:25:49 +08:00
|
|
|
|
static GimpTempBuf *
|
2001-02-07 08:06:58 +08:00
|
|
|
|
gimp_pattern_get_new_preview (GimpViewable *viewable,
|
2006-08-30 05:44:51 +08:00
|
|
|
|
GimpContext *context,
|
2005-07-24 06:22:45 +08:00
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
2001-02-05 23:22:20 +08:00
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
|
GimpPattern *pattern = GIMP_PATTERN (viewable);
|
2012-04-09 02:25:49 +08:00
|
|
|
|
GimpTempBuf *temp_buf;
|
2012-04-08 06:46:33 +08:00
|
|
|
|
GeglBuffer *src_buffer;
|
|
|
|
|
GeglBuffer *dest_buffer;
|
2001-02-06 05:52:57 +08:00
|
|
|
|
gint copy_width;
|
|
|
|
|
gint copy_height;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
2012-04-23 15:40:56 +08:00
|
|
|
|
copy_width = MIN (width, gimp_temp_buf_get_width (pattern->mask));
|
|
|
|
|
copy_height = MIN (height, gimp_temp_buf_get_height (pattern->mask));
|
2001-02-06 05:52:57 +08:00
|
|
|
|
|
2012-04-09 05:56:52 +08:00
|
|
|
|
temp_buf = gimp_temp_buf_new (copy_width, copy_height,
|
2012-04-23 15:40:56 +08:00
|
|
|
|
gimp_temp_buf_get_format (pattern->mask));
|
2001-02-06 05:52:57 +08:00
|
|
|
|
|
2012-04-09 06:16:46 +08:00
|
|
|
|
src_buffer = gimp_temp_buf_create_buffer (pattern->mask);
|
|
|
|
|
dest_buffer = gimp_temp_buf_create_buffer (temp_buf);
|
2012-04-08 06:46:33 +08:00
|
|
|
|
|
|
|
|
|
gegl_buffer_copy (src_buffer, GEGL_RECTANGLE (0, 0, copy_width, copy_height),
|
|
|
|
|
dest_buffer, GEGL_RECTANGLE (0, 0, 0, 0));
|
|
|
|
|
|
|
|
|
|
g_object_unref (src_buffer);
|
|
|
|
|
g_object_unref (dest_buffer);
|
2003-03-01 11:53:41 +08:00
|
|
|
|
|
2001-02-06 05:52:57 +08:00
|
|
|
|
return temp_buf;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-09 00:01:01 +08:00
|
|
|
|
static gchar *
|
|
|
|
|
gimp_pattern_get_description (GimpViewable *viewable,
|
|
|
|
|
gchar **tooltip)
|
|
|
|
|
{
|
2003-11-17 01:51:36 +08:00
|
|
|
|
GimpPattern *pattern = GIMP_PATTERN (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 (pattern),
|
2012-04-23 15:40:56 +08:00
|
|
|
|
gimp_temp_buf_get_width (pattern->mask),
|
|
|
|
|
gimp_temp_buf_get_height (pattern->mask));
|
2003-04-09 00:01:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-12 18:35:35 +08:00
|
|
|
|
static const gchar *
|
2001-02-14 03:53:07 +08:00
|
|
|
|
gimp_pattern_get_extension (GimpData *data)
|
|
|
|
|
{
|
|
|
|
|
return GIMP_PATTERN_FILE_EXTENSION;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-30 19:16:05 +08:00
|
|
|
|
static GimpData *
|
2005-06-08 19:27:31 +08:00
|
|
|
|
gimp_pattern_duplicate (GimpData *data)
|
2001-03-30 19:16:05 +08:00
|
|
|
|
{
|
2005-06-08 19:27:31 +08:00
|
|
|
|
GimpPattern *pattern = g_object_new (GIMP_TYPE_PATTERN, NULL);
|
2001-03-30 19:16:05 +08:00
|
|
|
|
|
2012-04-09 05:56:52 +08:00
|
|
|
|
pattern->mask = gimp_temp_buf_copy (GIMP_PATTERN (data)->mask);
|
2001-03-30 19:16:05 +08:00
|
|
|
|
|
|
|
|
|
return GIMP_DATA (pattern);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-13 19:58:24 +08:00
|
|
|
|
static gchar *
|
|
|
|
|
gimp_pattern_get_checksum (GimpTagged *tagged)
|
|
|
|
|
{
|
|
|
|
|
GimpPattern *pattern = GIMP_PATTERN (tagged);
|
|
|
|
|
gchar *checksum_string = NULL;
|
|
|
|
|
|
|
|
|
|
if (pattern->mask)
|
|
|
|
|
{
|
|
|
|
|
GChecksum *checksum = g_checksum_new (G_CHECKSUM_MD5);
|
|
|
|
|
|
2012-04-09 05:56:52 +08:00
|
|
|
|
g_checksum_update (checksum, gimp_temp_buf_get_data (pattern->mask),
|
|
|
|
|
gimp_temp_buf_get_data_size (pattern->mask));
|
2008-12-13 19:58:24 +08:00
|
|
|
|
|
|
|
|
|
checksum_string = g_strdup (g_checksum_get_string (checksum));
|
|
|
|
|
|
|
|
|
|
g_checksum_free (checksum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return checksum_string;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
|
GimpData *
|
2010-04-11 01:55:42 +08:00
|
|
|
|
gimp_pattern_new (GimpContext *context,
|
|
|
|
|
const gchar *name)
|
2001-02-14 03:53:07 +08:00
|
|
|
|
{
|
|
|
|
|
GimpPattern *pattern;
|
|
|
|
|
guchar *data;
|
|
|
|
|
gint row, col;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2010-04-11 01:55:42 +08:00
|
|
|
|
g_return_val_if_fail (name[0] != '\n', NULL);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
|
pattern = g_object_new (GIMP_TYPE_PATTERN,
|
|
|
|
|
"name", name,
|
|
|
|
|
NULL);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2012-04-09 05:56:52 +08:00
|
|
|
|
pattern->mask = gimp_temp_buf_new (32, 32, babl_format ("R'G'B' u8"));
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2012-04-09 05:56:52 +08:00
|
|
|
|
data = gimp_temp_buf_get_data (pattern->mask);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2012-04-23 15:40:56 +08:00
|
|
|
|
for (row = 0; row < gimp_temp_buf_get_height (pattern->mask); row++)
|
|
|
|
|
for (col = 0; col < gimp_temp_buf_get_width (pattern->mask); col++)
|
2001-02-14 03:53:07 +08:00
|
|
|
|
{
|
2005-07-24 06:22:45 +08:00
|
|
|
|
memset (data, (col % 2) && (row % 2) ? 255 : 0, 3);
|
|
|
|
|
data += 3;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
|
return GIMP_DATA (pattern);
|
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_pattern_get_standard (GimpContext *context)
|
2001-02-14 03:53:07 +08:00
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
|
static GimpData *standard_pattern = NULL;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
|
|
|
|
if (! standard_pattern)
|
|
|
|
|
{
|
2010-04-11 01:55:42 +08:00
|
|
|
|
standard_pattern = gimp_pattern_new (context, "Standard");
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
2009-11-01 01:48:38 +08:00
|
|
|
|
gimp_data_clean (standard_pattern);
|
|
|
|
|
gimp_data_make_internal (standard_pattern, "gimp-pattern-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_pattern),
|
|
|
|
|
(gpointer *) &standard_pattern);
|
2001-02-14 03:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
|
return standard_pattern;
|
2001-02-14 03:53:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-09 02:25:49 +08:00
|
|
|
|
GimpTempBuf *
|
2001-02-05 01:34:30 +08:00
|
|
|
|
gimp_pattern_get_mask (const GimpPattern *pattern)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
|
|
|
|
|
|
|
|
|
|
return pattern->mask;
|
|
|
|
|
}
|
2012-03-18 04:59:10 +08:00
|
|
|
|
|
|
|
|
|
GeglBuffer *
|
|
|
|
|
gimp_pattern_create_buffer (const GimpPattern *pattern)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
|
|
|
|
|
|
2012-04-09 06:16:46 +08:00
|
|
|
|
return gimp_temp_buf_create_buffer (pattern->mask);
|
2012-03-18 04:59:10 +08:00
|
|
|
|
}
|