2006-12-09 21:33:38 +00:00
|
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-06-26 12:09:43 +00:00
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-06-26 12:09:43 +00:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-06-26 12:09:43 +00: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-17 22:28:01 +00:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-06-26 12:09:43 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2012-05-03 03:36:22 +02:00
|
|
|
|
#include <cairo.h>
|
2012-03-14 23:09:36 +01:00
|
|
|
|
#include <gegl.h>
|
2012-05-03 03:36:22 +02:00
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
|
2012-04-24 01:21:37 +02:00
|
|
|
|
#include "gegl/gimp-babl.h"
|
2012-03-14 23:09:36 +01:00
|
|
|
|
|
2014-08-12 13:57:57 +02:00
|
|
|
|
#include "gimp-memsize.h"
|
2001-06-26 12:09:43 +00:00
|
|
|
|
#include "gimpbuffer.h"
|
2012-03-14 23:09:36 +01:00
|
|
|
|
#include "gimpimage.h"
|
2012-04-09 00:59:20 +02:00
|
|
|
|
#include "gimptempbuf.h"
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
|
|
|
|
|
2012-04-08 20:25:49 +02:00
|
|
|
|
static void gimp_buffer_finalize (GObject *object);
|
|
|
|
|
|
|
|
|
|
static gint64 gimp_buffer_get_memsize (GimpObject *object,
|
|
|
|
|
gint64 *gui_size);
|
|
|
|
|
|
|
|
|
|
static gboolean gimp_buffer_get_size (GimpViewable *viewable,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height);
|
|
|
|
|
static void gimp_buffer_get_preview_size (GimpViewable *viewable,
|
|
|
|
|
gint size,
|
|
|
|
|
gboolean is_popup,
|
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
|
gint *popup_width,
|
|
|
|
|
gint *popup_height);
|
|
|
|
|
static gboolean gimp_buffer_get_popup_size (GimpViewable *viewable,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
|
gint *popup_width,
|
|
|
|
|
gint *popup_height);
|
|
|
|
|
static GimpTempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height);
|
|
|
|
|
static gchar * gimp_buffer_get_description (GimpViewable *viewable,
|
|
|
|
|
gchar **tooltip);
|
2005-12-10 19:24:36 +00:00
|
|
|
|
|
|
|
|
|
|
2006-05-15 09:46:31 +00:00
|
|
|
|
G_DEFINE_TYPE (GimpBuffer, gimp_buffer, GIMP_TYPE_VIEWABLE)
|
2005-12-10 19:24:36 +00:00
|
|
|
|
|
|
|
|
|
#define parent_class gimp_buffer_parent_class
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_buffer_class_init (GimpBufferClass *klass)
|
|
|
|
|
{
|
2004-07-07 15:07:17 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
2014-05-07 01:01:56 +02:00
|
|
|
|
object_class->finalize = gimp_buffer_finalize;
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
2014-05-07 01:01:56 +02:00
|
|
|
|
gimp_object_class->get_memsize = gimp_buffer_get_memsize;
|
2002-01-30 16:14:26 +00:00
|
|
|
|
|
2014-05-07 01:01:56 +02:00
|
|
|
|
viewable_class->default_icon_name = "gtk-paste";
|
|
|
|
|
viewable_class->get_size = gimp_buffer_get_size;
|
|
|
|
|
viewable_class->get_preview_size = gimp_buffer_get_preview_size;
|
|
|
|
|
viewable_class->get_popup_size = gimp_buffer_get_popup_size;
|
|
|
|
|
viewable_class->get_new_preview = gimp_buffer_get_new_preview;
|
|
|
|
|
viewable_class->get_description = gimp_buffer_get_description;
|
2001-06-26 12:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_buffer_init (GimpBuffer *buffer)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2001-08-11 14:39:19 +00:00
|
|
|
|
gimp_buffer_finalize (GObject *object)
|
2001-06-26 12:09:43 +00:00
|
|
|
|
{
|
2004-07-07 15:07:17 +00:00
|
|
|
|
GimpBuffer *buffer = GIMP_BUFFER (object);
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
if (buffer->buffer)
|
2001-06-26 12:09:43 +00:00
|
|
|
|
{
|
2012-03-14 23:09:36 +01:00
|
|
|
|
g_object_unref (buffer->buffer);
|
|
|
|
|
buffer->buffer = NULL;
|
2001-06-26 12:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-16 23:16:54 +02:00
|
|
|
|
gimp_buffer_set_icc_profile (buffer, NULL, 0);
|
|
|
|
|
|
2001-08-11 14:39:19 +00:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-06-26 12:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 17:51:36 +00:00
|
|
|
|
static gint64
|
2003-08-25 10:49:33 +00:00
|
|
|
|
gimp_buffer_get_memsize (GimpObject *object,
|
2003-11-16 17:51:36 +00:00
|
|
|
|
gint64 *gui_size)
|
2002-01-30 16:14:26 +00:00
|
|
|
|
{
|
2005-05-25 10:05:17 +00:00
|
|
|
|
GimpBuffer *buffer = GIMP_BUFFER (object);
|
2003-11-16 17:51:36 +00:00
|
|
|
|
gint64 memsize = 0;
|
2002-01-30 16:14:26 +00:00
|
|
|
|
|
2012-03-21 21:58:40 +01:00
|
|
|
|
memsize += gimp_gegl_buffer_get_memsize (buffer->buffer);
|
2015-06-16 23:16:54 +02:00
|
|
|
|
memsize += buffer->icc_profile_len;
|
2002-01-30 16:14:26 +00:00
|
|
|
|
|
2003-08-25 10:49:33 +00:00
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
|
gui_size);
|
2002-01-30 16:14:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-05-25 10:05:17 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gimp_buffer_get_size (GimpViewable *viewable,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
|
|
|
|
{
|
|
|
|
|
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
|
|
|
|
|
|
|
|
|
*width = gimp_buffer_get_width (buffer);
|
|
|
|
|
*height = gimp_buffer_get_height (buffer);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-21 19:03:19 +00:00
|
|
|
|
static void
|
|
|
|
|
gimp_buffer_get_preview_size (GimpViewable *viewable,
|
2005-10-09 23:05:25 +00:00
|
|
|
|
gint size,
|
2003-02-21 19:03:19 +00:00
|
|
|
|
gboolean is_popup,
|
|
|
|
|
gboolean dot_for_dot,
|
2005-10-09 23:05:25 +00:00
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2003-02-21 19:03:19 +00:00
|
|
|
|
{
|
2003-11-17 13:34:38 +00:00
|
|
|
|
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
2003-02-21 19:03:19 +00:00
|
|
|
|
|
2003-11-17 13:34:38 +00:00
|
|
|
|
gimp_viewable_calc_preview_size (gimp_buffer_get_width (buffer),
|
2003-02-21 19:03:19 +00:00
|
|
|
|
gimp_buffer_get_height (buffer),
|
|
|
|
|
size,
|
|
|
|
|
size,
|
|
|
|
|
dot_for_dot, 1.0, 1.0,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-27 13:59:41 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gimp_buffer_get_popup_size (GimpViewable *viewable,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
|
gint *popup_width,
|
|
|
|
|
gint *popup_height)
|
|
|
|
|
{
|
|
|
|
|
GimpBuffer *buffer;
|
|
|
|
|
gint buffer_width;
|
|
|
|
|
gint buffer_height;
|
|
|
|
|
|
|
|
|
|
buffer = GIMP_BUFFER (viewable);
|
|
|
|
|
buffer_width = gimp_buffer_get_width (buffer);
|
|
|
|
|
buffer_height = gimp_buffer_get_height (buffer);
|
|
|
|
|
|
|
|
|
|
if (buffer_width > width || buffer_height > height)
|
|
|
|
|
{
|
|
|
|
|
gboolean scaling_up;
|
|
|
|
|
|
2003-11-17 13:34:38 +00:00
|
|
|
|
gimp_viewable_calc_preview_size (buffer_width,
|
2003-02-27 13:59:41 +00:00
|
|
|
|
buffer_height,
|
2003-10-09 12:26:46 +00:00
|
|
|
|
width * 2,
|
|
|
|
|
height * 2,
|
2003-02-27 13:59:41 +00:00
|
|
|
|
dot_for_dot, 1.0, 1.0,
|
|
|
|
|
popup_width,
|
|
|
|
|
popup_height,
|
|
|
|
|
&scaling_up);
|
|
|
|
|
|
|
|
|
|
if (scaling_up)
|
|
|
|
|
{
|
|
|
|
|
*popup_width = buffer_width;
|
|
|
|
|
*popup_height = buffer_height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-08 20:25:49 +02:00
|
|
|
|
static GimpTempBuf *
|
2001-06-26 12:09:43 +00:00
|
|
|
|
gimp_buffer_get_new_preview (GimpViewable *viewable,
|
2006-08-29 21:44:51 +00:00
|
|
|
|
GimpContext *context,
|
2005-10-09 23:05:25 +00:00
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
2001-06-26 12:09:43 +00:00
|
|
|
|
{
|
2012-04-08 20:25:49 +02:00
|
|
|
|
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
2012-04-24 01:21:37 +02:00
|
|
|
|
const Babl *format = gimp_buffer_get_format (buffer);
|
2012-04-08 20:25:49 +02:00
|
|
|
|
GimpTempBuf *preview;
|
2012-03-14 23:09:36 +01:00
|
|
|
|
|
2012-05-07 21:46:47 +02:00
|
|
|
|
if (babl_format_is_palette (format))
|
2013-06-23 16:51:24 +02:00
|
|
|
|
format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8_GAMMA,
|
2012-05-07 21:46:47 +02:00
|
|
|
|
babl_format_has_alpha (format));
|
|
|
|
|
else
|
|
|
|
|
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
|
2013-06-23 16:51:24 +02:00
|
|
|
|
GIMP_PRECISION_U8_GAMMA,
|
2012-05-07 21:46:47 +02:00
|
|
|
|
babl_format_has_alpha (format));
|
2003-03-01 03:53:41 +00:00
|
|
|
|
|
2012-04-24 01:21:37 +02:00
|
|
|
|
preview = gimp_temp_buf_new (width, height, format);
|
|
|
|
|
|
|
|
|
|
gegl_buffer_get (buffer->buffer, GEGL_RECTANGLE (0, 0, width, height),
|
2012-03-31 19:31:43 +02:00
|
|
|
|
MIN ((gdouble) width / (gdouble) gimp_buffer_get_width (buffer),
|
2012-03-14 23:09:36 +01:00
|
|
|
|
(gdouble) height / (gdouble) gimp_buffer_get_height (buffer)),
|
2012-04-24 01:21:37 +02:00
|
|
|
|
format,
|
2012-04-08 23:56:52 +02:00
|
|
|
|
gimp_temp_buf_get_data (preview),
|
2012-03-31 19:31:43 +02:00
|
|
|
|
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
2012-03-14 23:09:36 +01:00
|
|
|
|
|
|
|
|
|
return preview;
|
2001-06-26 12:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-08 16:01:01 +00:00
|
|
|
|
static gchar *
|
|
|
|
|
gimp_buffer_get_description (GimpViewable *viewable,
|
|
|
|
|
gchar **tooltip)
|
|
|
|
|
{
|
2004-07-02 14:08:15 +00:00
|
|
|
|
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
2003-04-08 16:01:01 +00:00
|
|
|
|
|
2006-02-28 12:15:51 +00:00
|
|
|
|
return g_strdup_printf ("%s (%d × %d)",
|
2009-08-29 12:40:40 +02:00
|
|
|
|
gimp_object_get_name (buffer),
|
2003-04-08 16:01:01 +00:00
|
|
|
|
gimp_buffer_get_width (buffer),
|
|
|
|
|
gimp_buffer_get_height (buffer));
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-26 12:09:43 +00:00
|
|
|
|
GimpBuffer *
|
2012-03-14 23:09:36 +01:00
|
|
|
|
gimp_buffer_new (GeglBuffer *buffer,
|
|
|
|
|
const gchar *name,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y,
|
|
|
|
|
gboolean copy_pixels)
|
2001-06-26 12:09:43 +00:00
|
|
|
|
{
|
2012-03-14 23:09:36 +01:00
|
|
|
|
GimpBuffer *gimp_buffer;
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
|
2001-06-26 12:09:43 +00:00
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
gimp_buffer = g_object_new (GIMP_TYPE_BUFFER,
|
|
|
|
|
"name", name,
|
|
|
|
|
NULL);
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
2012-08-24 22:31:42 +02:00
|
|
|
|
if (copy_pixels)
|
2012-03-14 23:09:36 +01:00
|
|
|
|
gimp_buffer->buffer = gegl_buffer_dup (buffer);
|
2001-12-12 23:48:18 +00:00
|
|
|
|
else
|
2012-03-14 23:09:36 +01:00
|
|
|
|
gimp_buffer->buffer = g_object_ref (buffer);
|
2001-06-26 12:09:43 +00:00
|
|
|
|
|
2012-04-07 02:43:18 +02:00
|
|
|
|
gimp_buffer->offset_x = offset_x;
|
|
|
|
|
gimp_buffer->offset_y = offset_y;
|
2011-03-26 08:30:15 +01:00
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
return gimp_buffer;
|
2001-06-26 12:09:43 +00:00
|
|
|
|
}
|
2001-12-12 23:48:18 +00:00
|
|
|
|
|
2005-04-09 21:52:21 +00:00
|
|
|
|
GimpBuffer *
|
|
|
|
|
gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
|
2011-03-26 08:30:15 +01:00
|
|
|
|
const gchar *name,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
2005-04-09 21:52:21 +00:00
|
|
|
|
{
|
2012-03-17 23:14:14 +01:00
|
|
|
|
GimpBuffer *gimp_buffer;
|
|
|
|
|
GeglBuffer *buffer;
|
2015-06-16 23:44:49 +02:00
|
|
|
|
guint8 *icc_data;
|
|
|
|
|
gsize icc_len;
|
2005-04-09 21:52:21 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
2012-03-17 23:14:14 +01:00
|
|
|
|
buffer = gimp_pixbuf_create_buffer (pixbuf);
|
2005-04-09 21:52:21 +00:00
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
gimp_buffer = gimp_buffer_new (buffer, name,
|
|
|
|
|
offset_x, offset_y, FALSE);
|
2010-03-19 09:52:29 +01:00
|
|
|
|
|
2015-06-16 23:44:49 +02:00
|
|
|
|
icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len);
|
2015-06-16 23:16:54 +02:00
|
|
|
|
|
2015-06-16 23:44:49 +02:00
|
|
|
|
if (icc_data)
|
2015-06-16 23:16:54 +02:00
|
|
|
|
{
|
2015-06-16 23:44:49 +02:00
|
|
|
|
gimp_buffer_set_icc_profile (gimp_buffer, icc_data, icc_len);
|
|
|
|
|
g_free (icc_data);
|
2015-06-16 23:16:54 +02:00
|
|
|
|
}
|
2015-08-15 19:15:14 +02:00
|
|
|
|
else if (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB)
|
|
|
|
|
{
|
|
|
|
|
GimpColorProfile *profile = gimp_color_profile_new_srgb ();
|
|
|
|
|
const guint8 *icc_data;
|
|
|
|
|
|
|
|
|
|
icc_data = gimp_color_profile_get_icc_profile (profile, &icc_len);
|
|
|
|
|
gimp_buffer_set_icc_profile (gimp_buffer, icc_data, icc_len);
|
|
|
|
|
|
|
|
|
|
g_object_unref (profile);
|
|
|
|
|
}
|
2015-06-16 23:16:54 +02:00
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
g_object_unref (buffer);
|
2010-03-19 09:52:29 +01:00
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
return gimp_buffer;
|
2005-04-09 21:52:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-12 23:48:18 +00:00
|
|
|
|
gint
|
2001-12-17 23:41:01 +00:00
|
|
|
|
gimp_buffer_get_width (const GimpBuffer *buffer)
|
2001-12-12 23:48:18 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
|
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
return gegl_buffer_get_width (buffer->buffer);
|
2001-12-12 23:48:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gint
|
2001-12-17 23:41:01 +00:00
|
|
|
|
gimp_buffer_get_height (const GimpBuffer *buffer)
|
2001-12-12 23:48:18 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
|
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
return gegl_buffer_get_height (buffer->buffer);
|
2001-12-12 23:48:18 +00:00
|
|
|
|
}
|
2005-09-27 09:05:55 +00:00
|
|
|
|
|
2012-03-31 19:31:43 +02:00
|
|
|
|
const Babl *
|
|
|
|
|
gimp_buffer_get_format (const GimpBuffer *buffer)
|
2005-09-27 09:05:55 +00:00
|
|
|
|
{
|
2012-03-31 19:31:43 +02:00
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
|
2005-09-27 09:05:55 +00:00
|
|
|
|
|
2012-03-31 19:31:43 +02:00
|
|
|
|
return gegl_buffer_get_format (buffer->buffer);
|
2005-09-27 09:05:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
GeglBuffer *
|
|
|
|
|
gimp_buffer_get_buffer (const GimpBuffer *buffer)
|
2008-08-07 17:23:45 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
|
|
|
|
|
|
2012-03-14 23:09:36 +01:00
|
|
|
|
return buffer->buffer;
|
2008-08-07 17:23:45 +00:00
|
|
|
|
}
|
2015-06-16 23:16:54 +02:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gimp_buffer_set_icc_profile (GimpBuffer *buffer,
|
|
|
|
|
const guint8 *data,
|
|
|
|
|
gsize length)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BUFFER (buffer));
|
|
|
|
|
g_return_if_fail (data == NULL || length != 0);
|
|
|
|
|
|
|
|
|
|
if (data != buffer->icc_profile)
|
|
|
|
|
{
|
|
|
|
|
if (buffer->icc_profile)
|
|
|
|
|
{
|
|
|
|
|
g_free (buffer->icc_profile);
|
|
|
|
|
buffer->icc_profile = NULL;
|
|
|
|
|
buffer->icc_profile_len = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
|
{
|
|
|
|
|
buffer->icc_profile = g_memdup (data, length);
|
|
|
|
|
buffer->icc_profile_len = length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const guint8 *
|
|
|
|
|
gimp_buffer_get_icc_profile (const GimpBuffer *buffer,
|
|
|
|
|
gsize *length)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
|
|
|
|
|
|
|
|
|
|
if (length)
|
|
|
|
|
*length = buffer->icc_profile_len;
|
|
|
|
|
|
|
|
|
|
return buffer->icc_profile;
|
|
|
|
|
}
|