Remove GimpUint8Array in favor of GBytes

GLib has a specific type for byte arrays: `GBytes` (and it's underlying
GType `G_TYPE_BYTES`).

By using this type, we can avoid having a `GimpUint8Array` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GBytes`, we allow other languages to pass on byte arrays as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with byte arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
This commit is contained in:
Niels De Graef 2023-05-23 23:37:46 +02:00
parent 9e79bb78a1
commit 89c359ce47
98 changed files with 841 additions and 1681 deletions

View File

@ -220,7 +220,6 @@ gimp_g_value_get_memsize (GValue *value)
NULL); NULL);
} }
else if (GIMP_VALUE_HOLDS_ARRAY (value) || else if (GIMP_VALUE_HOLDS_ARRAY (value) ||
GIMP_VALUE_HOLDS_UINT8_ARRAY (value) ||
GIMP_VALUE_HOLDS_INT32_ARRAY (value) || GIMP_VALUE_HOLDS_INT32_ARRAY (value) ||
GIMP_VALUE_HOLDS_FLOAT_ARRAY (value)) GIMP_VALUE_HOLDS_FLOAT_ARRAY (value))
{ {
@ -230,6 +229,15 @@ gimp_g_value_get_memsize (GValue *value)
memsize += sizeof (GimpArray) + memsize += sizeof (GimpArray) +
(array->static_data ? 0 : array->length); (array->static_data ? 0 : array->length);
} }
else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
{
GBytes *bytes = g_value_get_boxed (value);
if (bytes)
{
memsize += g_bytes_get_size (bytes);
}
}
else if (G_VALUE_HOLDS (value, G_TYPE_STRV)) else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
{ {
gchar **array = g_value_get_boxed (value); gchar **array = g_value_get_boxed (value);

View File

@ -332,11 +332,9 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
gint width = 0; gint width = 0;
gint height = 0; gint height = 0;
gint mask_bpp = 0; gint mask_bpp = 0;
gint num_mask_bytes = 0; GBytes *mask_bytes = NULL;
guint8 *mask_bytes = NULL;
gint color_bpp = 0; gint color_bpp = 0;
gint num_color_bytes = 0; GBytes *color_bytes = NULL;
guint8 *color_bytes = NULL;
brush = g_value_get_object (gimp_value_array_index (args, 0)); brush = g_value_get_object (gimp_value_array_index (args, 0));
@ -346,6 +344,8 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush); GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush);
const Babl *format; const Babl *format;
gpointer data; gpointer data;
gsize num_mask_bytes;
gsize num_color_bytes;
format = gimp_babl_compat_u8_mask_format ( format = gimp_babl_compat_u8_mask_format (
gimp_temp_buf_get_format (mask)); gimp_temp_buf_get_format (mask));
@ -356,7 +356,7 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
mask_bpp = babl_format_get_bytes_per_pixel (format); mask_bpp = babl_format_get_bytes_per_pixel (format);
num_mask_bytes = gimp_temp_buf_get_height (mask) * num_mask_bytes = gimp_temp_buf_get_height (mask) *
gimp_temp_buf_get_width (mask) * mask_bpp; gimp_temp_buf_get_width (mask) * mask_bpp;
mask_bytes = g_memdup2 (data, num_mask_bytes); mask_bytes = g_bytes_new (data, num_mask_bytes);
gimp_temp_buf_unlock (mask, data); gimp_temp_buf_unlock (mask, data);
@ -370,7 +370,7 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
num_color_bytes = gimp_temp_buf_get_height (pixmap) * num_color_bytes = gimp_temp_buf_get_height (pixmap) *
gimp_temp_buf_get_width (pixmap) * gimp_temp_buf_get_width (pixmap) *
color_bpp; color_bpp;
color_bytes = g_memdup2 (data, num_color_bytes); color_bytes = g_bytes_new (data, num_color_bytes);
gimp_temp_buf_unlock (pixmap, data); gimp_temp_buf_unlock (pixmap, data);
} }
@ -384,11 +384,9 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
g_value_set_int (gimp_value_array_index (return_vals, 1), width); g_value_set_int (gimp_value_array_index (return_vals, 1), width);
g_value_set_int (gimp_value_array_index (return_vals, 2), height); g_value_set_int (gimp_value_array_index (return_vals, 2), height);
g_value_set_int (gimp_value_array_index (return_vals, 3), mask_bpp); g_value_set_int (gimp_value_array_index (return_vals, 3), mask_bpp);
g_value_set_int (gimp_value_array_index (return_vals, 4), num_mask_bytes); g_value_take_boxed (gimp_value_array_index (return_vals, 4), mask_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), mask_bytes, num_mask_bytes); g_value_set_int (gimp_value_array_index (return_vals, 5), color_bpp);
g_value_set_int (gimp_value_array_index (return_vals, 6), color_bpp); g_value_take_boxed (gimp_value_array_index (return_vals, 6), color_bytes);
g_value_set_int (gimp_value_array_index (return_vals, 7), num_color_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 8), color_bytes, num_color_bytes);
} }
return return_vals; return return_vals;
@ -1186,16 +1184,11 @@ register_brush_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-mask-bytes", g_param_spec_boxed ("mask-bytes",
"num mask bytes", "mask bytes",
"Length of brush mask data", "The brush mask data",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("mask-bytes",
"mask bytes",
"The brush mask data",
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("color-bpp", g_param_spec_int ("color-bpp",
"color bpp", "color bpp",
@ -1203,16 +1196,11 @@ register_brush_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-color-bytes", g_param_spec_boxed ("color-bytes",
"num color bytes", "color bytes",
"Length of brush color data", "The brush color data",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("color-bytes",
"color bytes",
"The brush color data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -594,100 +594,6 @@ drawable_update_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
} }
static GimpValueArray *
drawable_get_pixel_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpDrawable *drawable;
gint x_coord;
gint y_coord;
gint num_channels = 0;
guint8 *pixel = NULL;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
x_coord = g_value_get_int (gimp_value_array_index (args, 1));
y_coord = g_value_get_int (gimp_value_array_index (args, 2));
if (success)
{
const Babl *format = gimp_drawable_get_format (drawable);
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
num_channels = babl_format_get_bytes_per_pixel (format);
pixel = g_new0 (guint8, num_channels);
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
x_coord, y_coord, NULL, pixel, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_channels);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 2), pixel, num_channels);
}
return return_vals;
}
static GimpValueArray *
drawable_set_pixel_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint x_coord;
gint y_coord;
gint num_channels;
const guint8 *pixel;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
x_coord = g_value_get_int (gimp_value_array_index (args, 1));
y_coord = g_value_get_int (gimp_value_array_index (args, 2));
num_channels = g_value_get_int (gimp_value_array_index (args, 3));
pixel = gimp_value_get_uint8_array (gimp_value_array_index (args, 4));
if (success)
{
const Babl *format = gimp_drawable_get_format (drawable);
if (gimp_pdb_item_is_modifiable (GIMP_ITEM (drawable),
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
num_channels == babl_format_get_bytes_per_pixel (format))
{
gegl_buffer_set (gimp_drawable_get_buffer (drawable),
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
0, format, pixel, GEGL_AUTO_ROWSTRIDE);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray * static GimpValueArray *
drawable_fill_invoker (GimpProcedure *procedure, drawable_fill_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -771,8 +677,7 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
gint actual_width = 0; gint actual_width = 0;
gint actual_height = 0; gint actual_height = 0;
gint bpp = 0; gint bpp = 0;
gint thumbnail_data_count = 0; GBytes *thumbnail_data = NULL;
guint8 *thumbnail_data = NULL;
drawable = g_value_get_object (gimp_value_array_index (args, 0)); drawable = g_value_get_object (gimp_value_array_index (args, 0));
width = g_value_get_int (gimp_value_array_index (args, 1)); width = g_value_get_int (gimp_value_array_index (args, 1));
@ -808,9 +713,8 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
actual_width = gimp_temp_buf_get_width (buf); actual_width = gimp_temp_buf_get_width (buf);
actual_height = gimp_temp_buf_get_height (buf); actual_height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf)); bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf); thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
thumbnail_data = g_memdup2 (gimp_temp_buf_get_data (buf), gimp_temp_buf_get_data_size (buf));
thumbnail_data_count);
gimp_temp_buf_unref (buf); gimp_temp_buf_unref (buf);
} }
@ -826,8 +730,7 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
g_value_set_int (gimp_value_array_index (return_vals, 1), actual_width); g_value_set_int (gimp_value_array_index (return_vals, 1), actual_width);
g_value_set_int (gimp_value_array_index (return_vals, 2), actual_height); g_value_set_int (gimp_value_array_index (return_vals, 2), actual_height);
g_value_set_int (gimp_value_array_index (return_vals, 3), bpp); g_value_set_int (gimp_value_array_index (return_vals, 3), bpp);
g_value_set_int (gimp_value_array_index (return_vals, 4), thumbnail_data_count); g_value_take_boxed (gimp_value_array_index (return_vals, 4), thumbnail_data);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), thumbnail_data, thumbnail_data_count);
} }
return return_vals; return return_vals;
@ -853,8 +756,7 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
gint width = 0; gint width = 0;
gint height = 0; gint height = 0;
gint bpp = 0; gint bpp = 0;
gint thumbnail_data_count = 0; GBytes *thumbnail_data = NULL;
guint8 *thumbnail_data = NULL;
drawable = g_value_get_object (gimp_value_array_index (args, 0)); drawable = g_value_get_object (gimp_value_array_index (args, 0));
src_x = g_value_get_int (gimp_value_array_index (args, 1)); src_x = g_value_get_int (gimp_value_array_index (args, 1));
@ -887,9 +789,8 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
width = gimp_temp_buf_get_width (buf); width = gimp_temp_buf_get_width (buf);
height = gimp_temp_buf_get_height (buf); height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf)); bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf); thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
thumbnail_data = g_memdup2 (gimp_temp_buf_get_data (buf), gimp_temp_buf_get_data_size (buf));
thumbnail_data_count);
gimp_temp_buf_unref (buf); gimp_temp_buf_unref (buf);
} }
@ -908,8 +809,7 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
g_value_set_int (gimp_value_array_index (return_vals, 1), width); g_value_set_int (gimp_value_array_index (return_vals, 1), width);
g_value_set_int (gimp_value_array_index (return_vals, 2), height); g_value_set_int (gimp_value_array_index (return_vals, 2), height);
g_value_set_int (gimp_value_array_index (return_vals, 3), bpp); g_value_set_int (gimp_value_array_index (return_vals, 3), bpp);
g_value_set_int (gimp_value_array_index (return_vals, 4), thumbnail_data_count); g_value_take_boxed (gimp_value_array_index (return_vals, 4), thumbnail_data);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), thumbnail_data, thumbnail_data_count);
} }
return return_vals; return return_vals;
@ -1547,98 +1447,6 @@ register_drawable_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-drawable-get-pixel
*/
procedure = gimp_procedure_new (drawable_get_pixel_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-get-pixel");
gimp_procedure_set_static_help (procedure,
"Gets the value of the pixel at the specified coordinates.",
"This procedure gets the pixel value at the specified coordinates. The 'num_channels' argument must always be equal to the bytes-per-pixel value for the specified drawable.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable ("drawable",
"drawable",
"The drawable",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("x-coord",
"x coord",
"The x coordinate",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("y-coord",
"y coord",
"The y coordinate",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-channels",
"num channels",
"The number of channels for the pixel",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("pixel",
"pixel",
"The pixel value",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-drawable-set-pixel
*/
procedure = gimp_procedure_new (drawable_set_pixel_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-drawable-set-pixel");
gimp_procedure_set_static_help (procedure,
"Sets the value of the pixel at the specified coordinates.",
"This procedure sets the pixel value at the specified coordinates. The 'num_channels' argument must always be equal to the bytes-per-pixel value for the specified drawable. Note that this function is not undoable, you should use it only on drawables you just created yourself.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable ("drawable",
"drawable",
"The drawable",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("x-coord",
"x coord",
"The x coordinate",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("y-coord",
"y coord",
"The y coordinate",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-channels",
"num channels",
"The number of channels for the pixel",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("pixel",
"pixel",
"The pixel value",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-drawable-fill * gimp-drawable-fill
*/ */
@ -1769,16 +1577,11 @@ register_drawable_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("thumbnail-data-count", g_param_spec_boxed ("thumbnail-data",
"thumbnail data count", "thumbnail data",
"The number of bytes in thumbnail data", "The thumbnail data",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("thumbnail-data",
"thumbnail data",
"The thumbnail data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -1857,16 +1660,11 @@ register_drawable_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("thumbnail-data-count", g_param_spec_boxed ("thumbnail-data",
"thumbnail data count", "thumbnail data",
"The number of bytes in thumbnail data", "The thumbnail data",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("thumbnail-data",
"thumbnail data",
"The thumbnail data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -292,8 +292,7 @@ file_load_thumbnail_invoker (GimpProcedure *procedure,
GFile *file; GFile *file;
gint width = 0; gint width = 0;
gint height = 0; gint height = 0;
gint thumb_data_count = 0; GBytes *thumb_data = NULL;
guint8 *thumb_data = NULL;
file = g_value_get_object (gimp_value_array_index (args, 0)); file = g_value_get_object (gimp_value_array_index (args, 0));
@ -305,9 +304,8 @@ file_load_thumbnail_invoker (GimpProcedure *procedure,
{ {
width = gdk_pixbuf_get_width (pixbuf); width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf); height = gdk_pixbuf_get_height (pixbuf);
thumb_data_count = 3 * width * height; thumb_data = g_bytes_new (gdk_pixbuf_get_pixels (pixbuf),
thumb_data = g_memdup2 (gdk_pixbuf_get_pixels (pixbuf), 3 * width * height);
thumb_data_count);
g_object_unref (pixbuf); g_object_unref (pixbuf);
} }
@ -322,8 +320,7 @@ file_load_thumbnail_invoker (GimpProcedure *procedure,
{ {
g_value_set_int (gimp_value_array_index (return_vals, 1), width); g_value_set_int (gimp_value_array_index (return_vals, 1), width);
g_value_set_int (gimp_value_array_index (return_vals, 2), height); g_value_set_int (gimp_value_array_index (return_vals, 2), height);
g_value_set_int (gimp_value_array_index (return_vals, 3), thumb_data_count); g_value_take_boxed (gimp_value_array_index (return_vals, 3), thumb_data);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 4), thumb_data, thumb_data_count);
} }
return return_vals; return return_vals;
@ -571,16 +568,11 @@ register_file_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("thumb-data-count", g_param_spec_boxed ("thumb-data",
"thumb data count", "thumb data",
"The number of bytes in thumbnail data", "The thumbnail data",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("thumb-data",
"thumb data",
"The thumbnail data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -446,7 +446,6 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
} }
if (GIMP_VALUE_HOLDS_INT32_ARRAY (value) || if (GIMP_VALUE_HOLDS_INT32_ARRAY (value) ||
GIMP_VALUE_HOLDS_UINT8_ARRAY (value) ||
GIMP_VALUE_HOLDS_FLOAT_ARRAY (value) || GIMP_VALUE_HOLDS_FLOAT_ARRAY (value) ||
GIMP_VALUE_HOLDS_RGB_ARRAY (value) || GIMP_VALUE_HOLDS_RGB_ARRAY (value) ||
GIMP_VALUE_HOLDS_OBJECT_ARRAY (value)) GIMP_VALUE_HOLDS_OBJECT_ARRAY (value))
@ -462,10 +461,6 @@ gimp_pdb_execute_procedure_by_name (GimpPDB *pdb,
gimp_value_set_int32_array (value, gimp_value_set_int32_array (value,
(const gint32 *) va_arg (va_args, gpointer), (const gint32 *) va_arg (va_args, gpointer),
prev_int_value); prev_int_value);
else if (GIMP_VALUE_HOLDS_UINT8_ARRAY (value))
gimp_value_set_uint8_array (value,
(const guint8 *) va_arg (va_args, gpointer),
prev_int_value);
else if (GIMP_VALUE_HOLDS_FLOAT_ARRAY (value)) else if (GIMP_VALUE_HOLDS_FLOAT_ARRAY (value))
gimp_value_set_float_array (value, gimp_value_set_float_array (value,
(const gdouble *) va_arg (va_args, gpointer), (const gdouble *) va_arg (va_args, gpointer),

View File

@ -1522,25 +1522,24 @@ image_get_colormap_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpImage *image; GimpImage *image;
gint num_bytes = 0; GBytes *colormap = NULL;
guint8 *colormap = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
if (success) if (success)
{ {
num_bytes = 3 * gimp_image_get_colormap_size (image); guchar *colormap_data;
colormap = gimp_image_get_colormap (image);
colormap_data = gimp_image_get_colormap (image);
colormap = g_bytes_new_take (colormap_data,
gimp_image_get_colormap_size (image));
} }
return_vals = gimp_procedure_get_return_values (procedure, success, return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL); error ? *error : NULL);
if (success) if (success)
{ g_value_take_boxed (gimp_value_array_index (return_vals, 1), colormap);
g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 2), colormap, num_bytes);
}
return return_vals; return return_vals;
} }
@ -1555,16 +1554,17 @@ image_set_colormap_invoker (GimpProcedure *procedure,
{ {
gboolean success = TRUE; gboolean success = TRUE;
GimpImage *image; GimpImage *image;
gint num_bytes; GBytes *colormap;
const guint8 *colormap;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
num_bytes = g_value_get_int (gimp_value_array_index (args, 1)); colormap = g_value_get_boxed (gimp_value_array_index (args, 1));
colormap = gimp_value_get_uint8_array (gimp_value_array_index (args, 2));
if (success) if (success)
{ {
gimp_image_set_colormap (image, colormap, num_bytes / 3, TRUE); gimp_image_set_colormap (image,
g_bytes_get_data (colormap, NULL),
g_bytes_get_size (colormap) / 3,
TRUE);
} }
return gimp_procedure_get_return_values (procedure, success, return gimp_procedure_get_return_values (procedure, success,
@ -1699,8 +1699,7 @@ image_thumbnail_invoker (GimpProcedure *procedure,
gint actual_width = 0; gint actual_width = 0;
gint actual_height = 0; gint actual_height = 0;
gint bpp = 0; gint bpp = 0;
gint thumbnail_data_count = 0; GBytes *thumbnail_data = NULL;
guint8 *thumbnail_data = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
width = g_value_get_int (gimp_value_array_index (args, 1)); width = g_value_get_int (gimp_value_array_index (args, 1));
@ -1732,9 +1731,8 @@ image_thumbnail_invoker (GimpProcedure *procedure,
actual_width = gimp_temp_buf_get_width (buf); actual_width = gimp_temp_buf_get_width (buf);
actual_height = gimp_temp_buf_get_height (buf); actual_height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf)); bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf); thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
thumbnail_data = g_memdup2 (gimp_temp_buf_get_data (buf), gimp_temp_buf_get_data_size (buf));
thumbnail_data_count);
gimp_temp_buf_unref (buf); gimp_temp_buf_unref (buf);
} }
@ -1750,8 +1748,7 @@ image_thumbnail_invoker (GimpProcedure *procedure,
g_value_set_int (gimp_value_array_index (return_vals, 1), actual_width); g_value_set_int (gimp_value_array_index (return_vals, 1), actual_width);
g_value_set_int (gimp_value_array_index (return_vals, 2), actual_height); g_value_set_int (gimp_value_array_index (return_vals, 2), actual_height);
g_value_set_int (gimp_value_array_index (return_vals, 3), bpp); g_value_set_int (gimp_value_array_index (return_vals, 3), bpp);
g_value_set_int (gimp_value_array_index (return_vals, 4), thumbnail_data_count); g_value_take_boxed (gimp_value_array_index (return_vals, 4), thumbnail_data);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), thumbnail_data, thumbnail_data_count);
} }
return return_vals; return return_vals;
@ -4318,16 +4315,11 @@ register_image_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("colormap",
"num bytes", "colormap",
"Number of bytes in the colormap array", "The image's colormap.",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("colormap",
"colormap",
"The image's colormap.",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -4352,16 +4344,11 @@ register_image_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("colormap",
"num bytes", "colormap",
"Number of bytes in the colormap array", "The new colormap values",
0, 768, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("colormap",
"colormap",
"The new colormap values",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -4528,16 +4515,11 @@ register_image_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("thumbnail-data-count", g_param_spec_boxed ("thumbnail-data",
"thumbnail data count", "thumbnail data",
"The number of bytes in thumbnail data", "The thumbnail data",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("thumbnail-data",
"thumbnail data",
"The thumbnail data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -55,8 +55,7 @@ image_get_color_profile_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpImage *image; GimpImage *image;
gint num_bytes = 0; GBytes *profile_data = NULL;
guint8 *profile_data = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
@ -73,8 +72,7 @@ image_get_color_profile_invoker (GimpProcedure *procedure,
data = gimp_color_profile_get_icc_profile (profile, &length); data = gimp_color_profile_get_icc_profile (profile, &length);
profile_data = g_memdup2 (data, length); profile_data = g_bytes_new (data, length);
num_bytes = length;
} }
} }
@ -82,10 +80,7 @@ image_get_color_profile_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
if (success) if (success)
{ g_value_take_boxed (gimp_value_array_index (return_vals, 1), profile_data);
g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes);
}
return return_vals; return return_vals;
} }
@ -101,8 +96,7 @@ image_get_effective_color_profile_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpImage *image; GimpImage *image;
gint num_bytes = 0; GBytes *profile_data = NULL;
guint8 *profile_data = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
@ -119,8 +113,7 @@ image_get_effective_color_profile_invoker (GimpProcedure *procedure,
data = gimp_color_profile_get_icc_profile (profile, &length); data = gimp_color_profile_get_icc_profile (profile, &length);
profile_data = g_memdup2 (data, length); profile_data = g_bytes_new (data, length);
num_bytes = length;
} }
} }
@ -128,10 +121,7 @@ image_get_effective_color_profile_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
if (success) if (success)
{ g_value_take_boxed (gimp_value_array_index (return_vals, 1), profile_data);
g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes);
}
return return_vals; return return_vals;
} }
@ -146,12 +136,10 @@ image_set_color_profile_invoker (GimpProcedure *procedure,
{ {
gboolean success = TRUE; gboolean success = TRUE;
GimpImage *image; GimpImage *image;
gint num_bytes; GBytes *color_profile;
const guint8 *color_profile;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
num_bytes = g_value_get_int (gimp_value_array_index (args, 1)); color_profile = g_value_get_boxed (gimp_value_array_index (args, 1));
color_profile = gimp_value_get_uint8_array (gimp_value_array_index (args, 2));
if (success) if (success)
{ {
@ -159,8 +147,8 @@ image_set_color_profile_invoker (GimpProcedure *procedure,
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (color_profile, profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
num_bytes, g_bytes_get_size (color_profile),
error); error);
if (profile) if (profile)
@ -237,8 +225,7 @@ image_get_simulation_profile_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpImage *image; GimpImage *image;
gint num_bytes = 0; GBytes *profile_data = NULL;
guint8 *profile_data = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
@ -255,8 +242,7 @@ image_get_simulation_profile_invoker (GimpProcedure *procedure,
data = gimp_color_profile_get_icc_profile (profile, &length); data = gimp_color_profile_get_icc_profile (profile, &length);
profile_data = g_memdup2 (data, length); profile_data = g_bytes_new (data, length);
num_bytes = length;
} }
} }
@ -264,10 +250,7 @@ image_get_simulation_profile_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
if (success) if (success)
{ g_value_take_boxed (gimp_value_array_index (return_vals, 1), profile_data);
g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes);
}
return return_vals; return return_vals;
} }
@ -282,12 +265,10 @@ image_set_simulation_profile_invoker (GimpProcedure *procedure,
{ {
gboolean success = TRUE; gboolean success = TRUE;
GimpImage *image; GimpImage *image;
gint num_bytes; GBytes *color_profile;
const guint8 *color_profile;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
num_bytes = g_value_get_int (gimp_value_array_index (args, 1)); color_profile = g_value_get_boxed (gimp_value_array_index (args, 1));
color_profile = gimp_value_get_uint8_array (gimp_value_array_index (args, 2));
if (success) if (success)
{ {
@ -295,8 +276,8 @@ image_set_simulation_profile_invoker (GimpProcedure *procedure,
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (color_profile, profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
num_bytes, g_bytes_get_size (color_profile),
error); error);
if (profile) if (profile)
@ -478,16 +459,14 @@ image_convert_color_profile_invoker (GimpProcedure *procedure,
{ {
gboolean success = TRUE; gboolean success = TRUE;
GimpImage *image; GimpImage *image;
gint num_bytes; GBytes *color_profile;
const guint8 *color_profile;
gint intent; gint intent;
gboolean bpc; gboolean bpc;
image = g_value_get_object (gimp_value_array_index (args, 0)); image = g_value_get_object (gimp_value_array_index (args, 0));
num_bytes = g_value_get_int (gimp_value_array_index (args, 1)); color_profile = g_value_get_boxed (gimp_value_array_index (args, 1));
color_profile = gimp_value_get_uint8_array (gimp_value_array_index (args, 2)); intent = g_value_get_enum (gimp_value_array_index (args, 2));
intent = g_value_get_enum (gimp_value_array_index (args, 3)); bpc = g_value_get_boolean (gimp_value_array_index (args, 3));
bpc = g_value_get_boolean (gimp_value_array_index (args, 4));
if (success) if (success)
{ {
@ -495,8 +474,8 @@ image_convert_color_profile_invoker (GimpProcedure *procedure,
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (color_profile, profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
num_bytes, g_bytes_get_size (color_profile),
error); error);
if (profile) if (profile)
@ -588,16 +567,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("profile-data",
"num bytes", "profile data",
"Number of bytes in the color_profile array", "The image's serialized color profile.",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("profile-data",
"profile data",
"The image's serialized color profile.",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -622,16 +596,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("profile-data",
"num bytes", "profile data",
"Number of bytes in the color_profile array", "The image's serialized color profile.",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("profile-data",
"profile data",
"The image's serialized color profile.",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -656,16 +625,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("color-profile",
"num bytes", "color profile",
"Number of bytes in the color_profile array", "The new serialized color profile",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("color-profile",
"color profile",
"The new serialized color profile",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -719,16 +683,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("profile-data",
"num bytes", "profile data",
"Number of bytes in the color_profile array", "The image's serialized simulation color profile.",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("profile-data",
"profile data",
"The image's serialized simulation color profile.",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -753,16 +712,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("color-profile",
"num bytes", "color profile",
"Number of bytes in the color_profile array", "The new serialized simulation color profile",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("color-profile",
"color profile",
"The new serialized simulation color profile",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -934,16 +888,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE, FALSE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("num-bytes", g_param_spec_boxed ("color-profile",
"num bytes", "color profile",
"Number of bytes in the color_profile array", "The serialized color profile",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("color-profile",
"color profile",
"The serialized color profile",
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_enum ("intent", g_param_spec_enum ("intent",
"intent", "intent",

View File

@ -198,19 +198,18 @@ image_convert_set_dither_matrix_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
gint width; gint width;
gint height; gint height;
gint matrix_length; GBytes *matrix;
const guint8 *matrix;
width = g_value_get_int (gimp_value_array_index (args, 0)); width = g_value_get_int (gimp_value_array_index (args, 0));
height = g_value_get_int (gimp_value_array_index (args, 1)); height = g_value_get_int (gimp_value_array_index (args, 1));
matrix_length = g_value_get_int (gimp_value_array_index (args, 2)); matrix = g_value_get_boxed (gimp_value_array_index (args, 2));
matrix = gimp_value_get_uint8_array (gimp_value_array_index (args, 3));
if (success) if (success)
{ {
if (width == 0 || height == 0 || matrix_length == width * height) if (width == 0 || height == 0 || g_bytes_get_size (matrix) == width * height)
{ {
gimp_image_convert_indexed_set_dither_matrix (matrix, width, height); gimp_image_convert_indexed_set_dither_matrix (g_bytes_get_data (matrix, NULL),
width, height);
} }
else else
{ {
@ -402,16 +401,11 @@ register_image_convert_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("matrix-length", g_param_spec_boxed ("matrix",
"matrix length", "matrix",
"The length of 'matrix'", "The matrix -- all values must be >= 1",
1, 1024, 1, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("matrix",
"matrix",
"The matrix -- all values must be >= 1",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -30,7 +30,7 @@
#include "internal-procs.h" #include "internal-procs.h"
/* 774 procedures registered total */ /* 772 procedures registered total */
void void
internal_procs_init (GimpPDB *pdb) internal_procs_init (GimpPDB *pdb)

View File

@ -100,8 +100,7 @@ pattern_get_pixels_invoker (GimpProcedure *procedure,
gint width = 0; gint width = 0;
gint height = 0; gint height = 0;
gint bpp = 0; gint bpp = 0;
gint num_color_bytes = 0; GBytes *color_bytes = NULL;
guint8 *color_bytes = NULL;
pattern = g_value_get_object (gimp_value_array_index (args, 0)); pattern = g_value_get_object (gimp_value_array_index (args, 0));
@ -118,8 +117,7 @@ pattern_get_pixels_invoker (GimpProcedure *procedure,
width = gimp_temp_buf_get_width (pattern->mask); width = gimp_temp_buf_get_width (pattern->mask);
height = gimp_temp_buf_get_height (pattern->mask); height = gimp_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (format); bpp = babl_format_get_bytes_per_pixel (format);
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask); color_bytes = g_bytes_new (data, gimp_temp_buf_get_data_size (pattern->mask));
color_bytes = g_memdup2 (data, num_color_bytes);
gimp_temp_buf_unlock (pattern->mask, data); gimp_temp_buf_unlock (pattern->mask, data);
} }
@ -132,8 +130,7 @@ pattern_get_pixels_invoker (GimpProcedure *procedure,
g_value_set_int (gimp_value_array_index (return_vals, 1), width); g_value_set_int (gimp_value_array_index (return_vals, 1), width);
g_value_set_int (gimp_value_array_index (return_vals, 2), height); g_value_set_int (gimp_value_array_index (return_vals, 2), height);
g_value_set_int (gimp_value_array_index (return_vals, 3), bpp); g_value_set_int (gimp_value_array_index (return_vals, 3), bpp);
g_value_set_int (gimp_value_array_index (return_vals, 4), num_color_bytes); g_value_take_boxed (gimp_value_array_index (return_vals, 4), color_bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 5), color_bytes, num_color_bytes);
} }
return return_vals; return return_vals;
@ -252,16 +249,11 @@ register_pattern_procs (GimpPDB *pdb)
G_MININT32, G_MAXINT32, 0, G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("num-color-bytes", g_param_spec_boxed ("color-bytes",
"num color bytes", "color bytes",
"Number of pattern bytes", "The pattern data.",
0, G_MAXINT32, 0, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("color-bytes",
"color bytes",
"The pattern data.",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -635,13 +635,11 @@ pdb_set_proc_icon_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
const gchar *procedure_name; const gchar *procedure_name;
gint icon_type; gint icon_type;
gint icon_data_length; GBytes *icon_data;
const guint8 *icon_data;
procedure_name = g_value_get_string (gimp_value_array_index (args, 0)); procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
icon_type = g_value_get_enum (gimp_value_array_index (args, 1)); icon_type = g_value_get_enum (gimp_value_array_index (args, 1));
icon_data_length = g_value_get_int (gimp_value_array_index (args, 2)); icon_data = g_value_get_boxed (gimp_value_array_index (args, 2));
icon_data = gimp_value_get_uint8_array (gimp_value_array_index (args, 3));
if (success) if (success)
{ {
@ -652,7 +650,8 @@ pdb_set_proc_icon_invoker (GimpProcedure *procedure,
{ {
success = gimp_plug_in_set_proc_icon (plug_in, procedure_name, success = gimp_plug_in_set_proc_icon (plug_in, procedure_name,
icon_type, icon_type,
icon_data, icon_data_length, g_bytes_get_data (icon_data, NULL),
g_bytes_get_size (icon_data),
error); error);
} }
else else
@ -1127,8 +1126,7 @@ pdb_get_data_invoker (GimpProcedure *procedure,
gboolean success = TRUE; gboolean success = TRUE;
GimpValueArray *return_vals; GimpValueArray *return_vals;
const gchar *identifier; const gchar *identifier;
gint bytes = 0; GBytes *data = NULL;
guint8 *data = NULL;
identifier = g_value_get_string (gimp_value_array_index (args, 0)); identifier = g_value_get_string (gimp_value_array_index (args, 0));
@ -1137,12 +1135,13 @@ pdb_get_data_invoker (GimpProcedure *procedure,
if (gimp_is_canonical_identifier (identifier)) if (gimp_is_canonical_identifier (identifier))
{ {
const guint8 *orig_data; const guint8 *orig_data;
gint bytes;
orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager, orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager,
identifier, &bytes); identifier, &bytes);
if (orig_data) if (orig_data)
data = g_memdup2 (orig_data, bytes); data = g_bytes_new (orig_data, bytes);
else else
success = FALSE; success = FALSE;
} }
@ -1159,10 +1158,7 @@ pdb_get_data_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
if (success) if (success)
{ g_value_take_boxed (gimp_value_array_index (return_vals, 1), data);
g_value_set_int (gimp_value_array_index (return_vals, 1), bytes);
gimp_value_take_uint8_array (gimp_value_array_index (return_vals, 2), data, bytes);
}
return return_vals; return return_vals;
} }
@ -1218,19 +1214,19 @@ pdb_set_data_invoker (GimpProcedure *procedure,
{ {
gboolean success = TRUE; gboolean success = TRUE;
const gchar *identifier; const gchar *identifier;
gint bytes; GBytes *data;
const guint8 *data;
identifier = g_value_get_string (gimp_value_array_index (args, 0)); identifier = g_value_get_string (gimp_value_array_index (args, 0));
bytes = g_value_get_int (gimp_value_array_index (args, 1)); data = g_value_get_boxed (gimp_value_array_index (args, 1));
data = gimp_value_get_uint8_array (gimp_value_array_index (args, 2));
if (success) if (success)
{ {
if (gimp_is_canonical_identifier (identifier)) if (gimp_is_canonical_identifier (identifier))
{ {
gimp_plug_in_manager_set_data (gimp->plug_in_manager, gimp_plug_in_manager_set_data (gimp->plug_in_manager,
identifier, bytes, data); identifier,
g_bytes_get_size (data),
g_bytes_get_data (data, NULL));
} }
else else
{ {
@ -1758,16 +1754,11 @@ register_pdb_procs (GimpPDB *pdb)
GIMP_ICON_TYPE_ICON_NAME, GIMP_ICON_TYPE_ICON_NAME,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("icon-data-length", g_param_spec_boxed ("icon-data",
"icon data length", "icon data",
"The length of 'icon-data'", "The procedure's icon. The format depends on the 'icon_type' parameter",
1, G_MAXINT32, 1, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("icon-data",
"icon data",
"The procedure's icon. The format depends on the 'icon_type' parameter",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -2227,16 +2218,11 @@ register_pdb_procs (GimpPDB *pdb)
NULL, NULL,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
g_param_spec_int ("bytes", g_param_spec_boxed ("data",
"bytes", "data",
"The number of bytes in the data", "A byte array containing data",
1, G_MAXINT32, 1, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_uint8_array ("data",
"data",
"A byte array containing data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -2292,16 +2278,11 @@ register_pdb_procs (GimpPDB *pdb)
NULL, NULL,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("bytes", g_param_spec_boxed ("data",
"bytes", "data",
"The number of bytes in the data", "A byte array containing data",
1, G_MAXINT32, 1, G_TYPE_BYTES,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_uint8_array ("data",
"data",
"A byte array containing data",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
} }

View File

@ -730,9 +730,7 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
GPParamDef *prev_param_def = &proc_install->params[i - 1]; GPParamDef *prev_param_def = &proc_install->params[i - 1];
if ((! strcmp (param_def->type_name, "GimpParamInt32Array") || if ((! strcmp (param_def->type_name, "GimpParamInt32Array") ||
! strcmp (param_def->type_name, "GimpParamUInt8Array") ||
! strcmp (param_def->type_name, "GimpParamIntFloatArray") || ! strcmp (param_def->type_name, "GimpParamIntFloatArray") ||
! strcmp (param_def->type_name, "GimpParamIntStringArray") ||
! strcmp (param_def->type_name, "GimpParamIntColorArray")) ! strcmp (param_def->type_name, "GimpParamIntColorArray"))
&& &&
strcmp (prev_param_def->type_name, "GParamInt")) strcmp (prev_param_def->type_name, "GParamInt"))

View File

@ -262,17 +262,16 @@ gimp_brush_select_run_callback (GimpPdbDialog *dialog,
GimpTempBuf *mask = gimp_brush_get_mask (brush); GimpTempBuf *mask = gimp_brush_get_mask (brush);
const Babl *format; const Babl *format;
gpointer data; gpointer data;
GimpArray *array; GBytes *bytes;
GimpValueArray *return_vals; GimpValueArray *return_vals;
format = gimp_babl_compat_u8_mask_format (gimp_temp_buf_get_format (mask)); format = gimp_babl_compat_u8_mask_format (gimp_temp_buf_get_format (mask));
data = gimp_temp_buf_lock (mask, format, GEGL_ACCESS_READ); data = gimp_temp_buf_lock (mask, format, GEGL_ACCESS_READ);
array = gimp_array_new (data, bytes = g_bytes_new_static (data,
gimp_temp_buf_get_width (mask) * gimp_temp_buf_get_width (mask) *
gimp_temp_buf_get_height (mask) * gimp_temp_buf_get_height (mask) *
babl_format_get_bytes_per_pixel (format), babl_format_get_bytes_per_pixel (format));
TRUE);
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name (dialog->pdb, gimp_pdb_execute_procedure_by_name (dialog->pdb,
@ -285,12 +284,11 @@ gimp_brush_select_run_callback (GimpPdbDialog *dialog,
GIMP_TYPE_LAYER_MODE, gimp_context_get_paint_mode (dialog->context), GIMP_TYPE_LAYER_MODE, gimp_context_get_paint_mode (dialog->context),
G_TYPE_INT, gimp_brush_get_width (brush), G_TYPE_INT, gimp_brush_get_width (brush),
G_TYPE_INT, gimp_brush_get_height (brush), G_TYPE_INT, gimp_brush_get_height (brush),
G_TYPE_INT, array->length, G_TYPE_BYTES, bytes,
GIMP_TYPE_UINT8_ARRAY, array->data,
G_TYPE_BOOLEAN, closing, G_TYPE_BOOLEAN, closing,
G_TYPE_NONE); G_TYPE_NONE);
gimp_array_free (array); g_bytes_unref (bytes);
gimp_temp_buf_unlock (mask, data); gimp_temp_buf_unlock (mask, data);

View File

@ -107,18 +107,17 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
GimpPattern *pattern = GIMP_PATTERN (object); GimpPattern *pattern = GIMP_PATTERN (object);
const Babl *format; const Babl *format;
gpointer data; gpointer data;
GimpArray *array; GBytes *bytes;
GimpValueArray *return_vals; GimpValueArray *return_vals;
format = gimp_babl_compat_u8_format ( format = gimp_babl_compat_u8_format (
gimp_temp_buf_get_format (pattern->mask)); gimp_temp_buf_get_format (pattern->mask));
data = gimp_temp_buf_lock (pattern->mask, format, GEGL_ACCESS_READ); data = gimp_temp_buf_lock (pattern->mask, format, GEGL_ACCESS_READ);
array = gimp_array_new (data, bytes = g_bytes_new_static (data,
gimp_temp_buf_get_width (pattern->mask) * gimp_temp_buf_get_width (pattern->mask) *
gimp_temp_buf_get_height (pattern->mask) * gimp_temp_buf_get_height (pattern->mask) *
babl_format_get_bytes_per_pixel (format), babl_format_get_bytes_per_pixel (format));
TRUE);
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name (dialog->pdb, gimp_pdb_execute_procedure_by_name (dialog->pdb,
@ -129,12 +128,11 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
G_TYPE_INT, gimp_temp_buf_get_width (pattern->mask), G_TYPE_INT, gimp_temp_buf_get_width (pattern->mask),
G_TYPE_INT, gimp_temp_buf_get_height (pattern->mask), G_TYPE_INT, gimp_temp_buf_get_height (pattern->mask),
G_TYPE_INT, babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask)), G_TYPE_INT, babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask)),
G_TYPE_INT, array->length, G_TYPE_BYTES, bytes,
GIMP_TYPE_UINT8_ARRAY, array->data,
G_TYPE_BOOLEAN, closing, G_TYPE_BOOLEAN, closing,
G_TYPE_NONE); G_TYPE_NONE);
gimp_array_free (array); g_bytes_unref (bytes);
gimp_temp_buf_unlock (pattern->mask, data); gimp_temp_buf_unlock (pattern->mask, data);

View File

@ -426,8 +426,9 @@ gimp_main (GType plug_in_type,
G_TYPE_STRING, G_TYPE_PARAM_STRING, G_TYPE_STRING, G_TYPE_PARAM_STRING,
G_TYPE_STRV, G_TYPE_PARAM_BOXED, G_TYPE_STRV, G_TYPE_PARAM_BOXED,
G_TYPE_BYTES, G_TYPE_PARAM_BOXED,
GIMP_TYPE_ARRAY, GIMP_TYPE_PARAM_ARRAY, GIMP_TYPE_ARRAY, GIMP_TYPE_PARAM_ARRAY,
GIMP_TYPE_UINT8_ARRAY, GIMP_TYPE_PARAM_UINT8_ARRAY,
GIMP_TYPE_INT32_ARRAY, GIMP_TYPE_PARAM_INT32_ARRAY, GIMP_TYPE_INT32_ARRAY, GIMP_TYPE_PARAM_INT32_ARRAY,
GIMP_TYPE_FLOAT_ARRAY, GIMP_TYPE_PARAM_FLOAT_ARRAY, GIMP_TYPE_FLOAT_ARRAY, GIMP_TYPE_PARAM_FLOAT_ARRAY,
GIMP_TYPE_RGB_ARRAY, GIMP_TYPE_PARAM_RGB_ARRAY, GIMP_TYPE_RGB_ARRAY, GIMP_TYPE_PARAM_RGB_ARRAY,

View File

@ -221,7 +221,6 @@ EXPORTS
gimp_drawable_get_format gimp_drawable_get_format
gimp_drawable_get_height gimp_drawable_get_height
gimp_drawable_get_offsets gimp_drawable_get_offsets
gimp_drawable_get_pixel
gimp_drawable_get_shadow_buffer gimp_drawable_get_shadow_buffer
gimp_drawable_get_sub_thumbnail gimp_drawable_get_sub_thumbnail
gimp_drawable_get_sub_thumbnail_data gimp_drawable_get_sub_thumbnail_data
@ -244,7 +243,6 @@ EXPORTS
gimp_drawable_merge_shadow gimp_drawable_merge_shadow
gimp_drawable_offset gimp_drawable_offset
gimp_drawable_posterize gimp_drawable_posterize
gimp_drawable_set_pixel
gimp_drawable_shadows_highlights gimp_drawable_shadows_highlights
gimp_drawable_threshold gimp_drawable_threshold
gimp_drawable_type gimp_drawable_type

View File

@ -314,31 +314,31 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview,
} }
else else
{ {
guchar *sel; GBytes *sel;
guchar *src; GBytes *src;
GimpSelection *selection; GimpSelection *selection;
gint w, h; gint w, h;
gint bpp; gint bpp;
selection = gimp_image_get_selection (image); selection = gimp_image_get_selection (image);
w = width;
h = height;
src = gimp_drawable_get_thumbnail_data (priv->drawable, src = gimp_drawable_get_thumbnail_data (priv->drawable,
width, height,
&w, &h, &bpp); &w, &h, &bpp);
sel = gimp_drawable_get_thumbnail_data (GIMP_DRAWABLE (selection), sel = gimp_drawable_get_thumbnail_data (GIMP_DRAWABLE (selection),
width, height,
&w, &h, &bpp); &w, &h, &bpp);
gimp_preview_area_mask (GIMP_PREVIEW_AREA (area), gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
0, 0, width, height, 0, 0, width, height,
gimp_drawable_type (priv->drawable), gimp_drawable_type (priv->drawable),
src, width * gimp_drawable_get_bpp (priv->drawable), g_bytes_get_data (src, NULL),
width * gimp_drawable_get_bpp (priv->drawable),
buffer, rowstride, buffer, rowstride,
sel, width); g_bytes_get_data (sel, NULL), width);
g_free (sel); g_bytes_unref (sel);
g_free (src); g_bytes_unref (src);
} }
} }

View File

@ -361,11 +361,9 @@ gimp_brush_get_info (GimpBrush *brush,
* @width: (out): The brush width. * @width: (out): The brush width.
* @height: (out): The brush height. * @height: (out): The brush height.
* @mask_bpp: (out): The brush mask bpp. * @mask_bpp: (out): The brush mask bpp.
* @num_mask_bytes: (out): Length of brush mask data. * @mask_bytes: (out) (transfer full): The brush mask data.
* @mask_bytes: (out) (array length=num_mask_bytes) (element-type guint8) (transfer full): The brush mask data.
* @color_bpp: (out): The brush color bpp. * @color_bpp: (out): The brush color bpp.
* @num_color_bytes: (out): Length of brush color data. * @color_bytes: (out) (transfer full): The brush color data.
* @color_bytes: (out) (array length=num_color_bytes) (element-type guint8) (transfer full): The brush color data.
* *
* Gets information about the brush. * Gets information about the brush.
* *
@ -382,11 +380,9 @@ gimp_brush_get_pixels (GimpBrush *brush,
gint *width, gint *width,
gint *height, gint *height,
gint *mask_bpp, gint *mask_bpp,
gint *num_mask_bytes, GBytes **mask_bytes,
guint8 **mask_bytes,
gint *color_bpp, gint *color_bpp,
gint *num_color_bytes, GBytes **color_bytes)
guint8 **color_bytes)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -404,10 +400,8 @@ gimp_brush_get_pixels (GimpBrush *brush,
*width = 0; *width = 0;
*height = 0; *height = 0;
*mask_bpp = 0; *mask_bpp = 0;
*num_mask_bytes = 0;
*mask_bytes = NULL; *mask_bytes = NULL;
*color_bpp = 0; *color_bpp = 0;
*num_color_bytes = 0;
*color_bytes = NULL; *color_bytes = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
@ -417,11 +411,9 @@ gimp_brush_get_pixels (GimpBrush *brush,
*width = GIMP_VALUES_GET_INT (return_vals, 1); *width = GIMP_VALUES_GET_INT (return_vals, 1);
*height = GIMP_VALUES_GET_INT (return_vals, 2); *height = GIMP_VALUES_GET_INT (return_vals, 2);
*mask_bpp = GIMP_VALUES_GET_INT (return_vals, 3); *mask_bpp = GIMP_VALUES_GET_INT (return_vals, 3);
*num_mask_bytes = GIMP_VALUES_GET_INT (return_vals, 4); *mask_bytes = GIMP_VALUES_DUP_BYTES (return_vals, 4);
*mask_bytes = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 5); *color_bpp = GIMP_VALUES_GET_INT (return_vals, 5);
*color_bpp = GIMP_VALUES_GET_INT (return_vals, 6); *color_bytes = GIMP_VALUES_DUP_BYTES (return_vals, 6);
*num_color_bytes = GIMP_VALUES_GET_INT (return_vals, 7);
*color_bytes = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 8);
} }
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View File

@ -49,11 +49,9 @@ gboolean gimp_brush_get_pixels (GimpBrush *brush,
gint *width, gint *width,
gint *height, gint *height,
gint *mask_bpp, gint *mask_bpp,
gint *num_mask_bytes, GBytes **mask_bytes,
guint8 **mask_bytes,
gint *color_bpp, gint *color_bpp,
gint *num_color_bytes, GBytes **color_bytes);
guint8 **color_bytes);
gint gimp_brush_get_spacing (GimpBrush *brush); gint gimp_brush_get_spacing (GimpBrush *brush);
gboolean gimp_brush_set_spacing (GimpBrush *brush, gboolean gimp_brush_set_spacing (GimpBrush *brush,
gint spacing); gint spacing);

View File

@ -405,10 +405,9 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self)
{ {
GimpBrush *brush; GimpBrush *brush;
gint mask_bpp; gint mask_bpp;
gint mask_data_size; GBytes *mask_data;
gint color_bpp; gint color_bpp;
gint color_data_size; GBytes *color_data;
guint8 *color_data;
_PreviewBitmap result; _PreviewBitmap result;
g_debug ("%s", G_STRFUNC); g_debug ("%s", G_STRFUNC);
@ -419,15 +418,13 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self)
&result.width, &result.width,
&result.height, &result.height,
&mask_bpp, &mask_bpp,
&mask_data_size, &mask_data,
&result.mask_data,
&color_bpp, &color_bpp,
&color_data_size,
&color_data); &color_data);
result.mask_data = g_bytes_unref_to_data (mask_data, NULL);
/* Discard any color data, bitmap is B&W i.e. i.e. depth one i.e. a mask */ /* Discard any color data, bitmap is B&W i.e. i.e. depth one i.e. a mask */
if (color_data) g_bytes_unref (color_data);
g_free (color_data);
return result; return result;
} }

View File

@ -73,39 +73,40 @@ gimp_drawable_get_by_id (gint32 drawable_id)
/** /**
* gimp_drawable_get_thumbnail_data: * gimp_drawable_get_thumbnail_data:
* @drawable: the drawable * @drawable: the drawable
* @width: (inout): the requested thumbnail width (<= 1024 pixels) * @width: the requested thumbnail width (<= 1024 pixels)
* @height: (inout): the requested thumbnail height (<= 1024 pixels) * @height: the requested thumbnail height (<= 1024 pixels)
* @bpp: (out): the bytes per pixel of the returned thubmnail data * @actual_width: (out): the resulting thumbnail's actual width
* @actual_height: (out): the resulting thumbnail's actual height
* @bpp: (out): the bytes per pixel of the returned thubmnail data
* *
* Retrieves thumbnail data for the drawable identified by @drawable. * Retrieves thumbnail data for the drawable identified by @drawable.
* The thumbnail will be not larger than the requested size. * The thumbnail will be not larger than the requested size.
* *
* Returns: (transfer full) (array) (nullable): thumbnail data or %NULL if * Returns: (transfer full) (nullable): thumbnail data or %NULL if
* @drawable is invalid. * @drawable is invalid.
**/ **/
guchar * GBytes *
gimp_drawable_get_thumbnail_data (GimpDrawable *drawable, gimp_drawable_get_thumbnail_data (GimpDrawable *drawable,
gint *width, gint width,
gint *height, gint height,
gint *actual_width,
gint *actual_height,
gint *bpp) gint *bpp)
{ {
gint ret_width; GBytes *image_data;
gint ret_height;
guchar *image_data; g_return_val_if_fail (actual_width != NULL, NULL);
gint data_size; g_return_val_if_fail (actual_height != NULL, NULL);
g_return_val_if_fail (bpp != NULL, NULL);
_gimp_drawable_thumbnail (drawable, _gimp_drawable_thumbnail (drawable,
*width, width,
*height, height,
&ret_width, actual_width,
&ret_height, actual_height,
bpp, bpp,
&data_size,
&image_data); &image_data);
*width = ret_width;
*height = ret_height;
return image_data; return image_data;
} }
@ -130,25 +131,27 @@ gimp_drawable_get_thumbnail (GimpDrawable *drawable,
gint height, gint height,
GimpPixbufTransparency alpha) GimpPixbufTransparency alpha)
{ {
gint thumb_width = width; gint thumb_width, thumb_height, thumb_bpp;
gint thumb_height = height; GBytes *data;
gint thumb_bpp; GdkPixbuf *pixbuf = NULL;
guchar *data;
g_return_val_if_fail (width > 0 && width <= 1024, NULL); g_return_val_if_fail (width > 0 && width <= 1024, NULL);
g_return_val_if_fail (height > 0 && height <= 1024, NULL); g_return_val_if_fail (height > 0 && height <= 1024, NULL);
data = gimp_drawable_get_thumbnail_data (drawable, data = gimp_drawable_get_thumbnail_data (drawable,
width,
height,
&thumb_width, &thumb_width,
&thumb_height, &thumb_height,
&thumb_bpp); &thumb_bpp);
if (data) if (data)
return _gimp_pixbuf_from_data (data, pixbuf = _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, NULL),
thumb_width, thumb_height, thumb_bpp, thumb_width, thumb_height, thumb_bpp,
alpha); alpha);
return NULL; g_bytes_unref (data);
return pixbuf;
} }
/** /**
@ -158,46 +161,48 @@ gimp_drawable_get_thumbnail (GimpDrawable *drawable,
* @src_y: the y coordinate of the area * @src_y: the y coordinate of the area
* @src_width: the width of the area * @src_width: the width of the area
* @src_height: the height of the area * @src_height: the height of the area
* @dest_width: (inout): the requested thumbnail width (<= 1024 pixels) * @dest_width: the requested thumbnail width (<= 1024 pixels)
* @dest_height: (inout): the requested thumbnail height (<= 1024 pixels) * @dest_height: the requested thumbnail height (<= 1024 pixels)
* @actual_width: (out): the width of the returned thumbnail
* @actual_height: (out): the height of the returned thumbnail
* @bpp: (out): the bytes per pixel of the returned thumbnail data * @bpp: (out): the bytes per pixel of the returned thumbnail data
* *
* Retrieves thumbnail data for the drawable identified by @drawable. * Retrieves thumbnail data for the drawable identified by @drawable.
* The thumbnail will be not larger than the requested size. * The thumbnail will be not larger than the requested size.
* *
* Returns: (transfer full) (array) (nullable): thumbnail data or %NULL if * Returns: (transfer full): thumbnail data or %NULL if
* @drawable is invalid. * @drawable is invalid.
**/ **/
guchar * GBytes *
gimp_drawable_get_sub_thumbnail_data (GimpDrawable *drawable, gimp_drawable_get_sub_thumbnail_data (GimpDrawable *drawable,
gint src_x, gint src_x,
gint src_y, gint src_y,
gint src_width, gint src_width,
gint src_height, gint src_height,
gint *dest_width, gint dest_width,
gint *dest_height, gint dest_height,
gint *actual_width,
gint *actual_height,
gint *bpp) gint *bpp)
{ {
gint ret_width; gint ret_width, ret_height;
gint ret_height; GBytes *image_bytes;
guchar *image_data; gsize data_size;
gint data_size;
_gimp_drawable_sub_thumbnail (drawable, _gimp_drawable_sub_thumbnail (drawable,
src_x, src_y, src_x, src_y,
src_width, src_height, src_width, src_height,
*dest_width, dest_width,
*dest_height, dest_height,
&ret_width, &ret_width,
&ret_height, &ret_height,
bpp, bpp,
&data_size, &image_bytes);
&image_data);
*dest_width = ret_width; *actual_width = ret_width;
*dest_height = ret_height; *actual_height = ret_height;
return image_data; return g_bytes_unref_to_data (image_bytes, &data_size);
} }
/** /**
@ -229,10 +234,11 @@ gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
gint dest_height, gint dest_height,
GimpPixbufTransparency alpha) GimpPixbufTransparency alpha)
{ {
gint thumb_width = dest_width; gint thumb_width = dest_width;
gint thumb_height = dest_height; gint thumb_height = dest_height;
gint thumb_bpp; gint thumb_bpp;
guchar *data; GBytes *data;
GdkPixbuf *pixbuf = NULL;
g_return_val_if_fail (src_x >= 0, NULL); g_return_val_if_fail (src_x >= 0, NULL);
g_return_val_if_fail (src_y >= 0, NULL); g_return_val_if_fail (src_y >= 0, NULL);
@ -244,16 +250,18 @@ gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
data = gimp_drawable_get_sub_thumbnail_data (drawable, data = gimp_drawable_get_sub_thumbnail_data (drawable,
src_x, src_y, src_x, src_y,
src_width, src_height, src_width, src_height,
dest_width, dest_height,
&thumb_width, &thumb_width,
&thumb_height, &thumb_height,
&thumb_bpp); &thumb_bpp);
if (data) if (data)
return _gimp_pixbuf_from_data (data, pixbuf = _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, NULL),
thumb_width, thumb_height, thumb_bpp, thumb_width, thumb_height, thumb_bpp,
alpha); alpha);
g_bytes_unref (data);
return NULL; return pixbuf;
} }
/** /**
@ -375,7 +383,7 @@ gimp_drawable_get_format (GimpDrawable *drawable)
const Babl *palette; const Babl *palette;
const Babl *palette_alpha; const Babl *palette_alpha;
guchar *colormap; guchar *colormap;
gint n_colors; gint colormap_len, n_colors;
babl_new_palette_with_space (format_str, space, babl_new_palette_with_space (format_str, space,
&palette, &palette_alpha); &palette, &palette_alpha);
@ -385,7 +393,7 @@ gimp_drawable_get_format (GimpDrawable *drawable)
else else
format = palette; format = palette;
colormap = gimp_image_get_colormap (image, &n_colors); colormap = gimp_image_get_colormap (image, &colormap_len, &n_colors);
if (colormap) if (colormap)
{ {

View File

@ -62,22 +62,26 @@ GeglBuffer * gimp_drawable_get_shadow_buffer (GimpDrawable *drawable);
const Babl * gimp_drawable_get_format (GimpDrawable *drawable); const Babl * gimp_drawable_get_format (GimpDrawable *drawable);
const Babl * gimp_drawable_get_thumbnail_format (GimpDrawable *drawable); const Babl * gimp_drawable_get_thumbnail_format (GimpDrawable *drawable);
guchar * gimp_drawable_get_thumbnail_data (GimpDrawable *drawable, GBytes * gimp_drawable_get_thumbnail_data (GimpDrawable *drawable,
gint *width, gint width,
gint *height, gint height,
gint *actual_width,
gint *actual_height,
gint *bpp); gint *bpp);
GdkPixbuf * gimp_drawable_get_thumbnail (GimpDrawable *drawable, GdkPixbuf * gimp_drawable_get_thumbnail (GimpDrawable *drawable,
gint width, gint width,
gint height, gint height,
GimpPixbufTransparency alpha); GimpPixbufTransparency alpha);
guchar * gimp_drawable_get_sub_thumbnail_data (GimpDrawable *drawable, GBytes * gimp_drawable_get_sub_thumbnail_data (GimpDrawable *drawable,
gint src_x, gint src_x,
gint src_y, gint src_y,
gint src_width, gint src_width,
gint src_height, gint src_height,
gint *dest_width, gint dest_width,
gint *dest_height, gint dest_height,
gint *actual_width,
gint *actual_height,
gint *bpp); gint *bpp);
GdkPixbuf * gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable, GdkPixbuf * gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
gint src_x, gint src_x,

View File

@ -717,107 +717,6 @@ gimp_drawable_update (GimpDrawable *drawable,
return success; return success;
} }
/**
* gimp_drawable_get_pixel:
* @drawable: The drawable.
* @x_coord: The x coordinate.
* @y_coord: The y coordinate.
* @num_channels: (out): The number of channels for the pixel.
*
* Gets the value of the pixel at the specified coordinates.
*
* This procedure gets the pixel value at the specified coordinates.
* The 'num_channels' argument must always be equal to the
* bytes-per-pixel value for the specified drawable.
*
* Returns: (array length=num_channels) (element-type guint8) (transfer full):
* The pixel value.
* The returned value must be freed with g_free().
**/
guint8 *
gimp_drawable_get_pixel (GimpDrawable *drawable,
gint x_coord,
gint y_coord,
gint *num_channels)
{
GimpValueArray *args;
GimpValueArray *return_vals;
guint8 *pixel = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_DRAWABLE, drawable,
G_TYPE_INT, x_coord,
G_TYPE_INT, y_coord,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-drawable-get-pixel",
args);
gimp_value_array_unref (args);
*num_channels = 0;
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{
*num_channels = GIMP_VALUES_GET_INT (return_vals, 1);
pixel = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals);
return pixel;
}
/**
* gimp_drawable_set_pixel:
* @drawable: The drawable.
* @x_coord: The x coordinate.
* @y_coord: The y coordinate.
* @num_channels: The number of channels for the pixel.
* @pixel: (array length=num_channels) (element-type guint8): The pixel value.
*
* Sets the value of the pixel at the specified coordinates.
*
* This procedure sets the pixel value at the specified coordinates.
* The 'num_channels' argument must always be equal to the
* bytes-per-pixel value for the specified drawable. Note that this
* function is not undoable, you should use it only on drawables you
* just created yourself.
*
* Returns: TRUE on success.
**/
gboolean
gimp_drawable_set_pixel (GimpDrawable *drawable,
gint x_coord,
gint y_coord,
gint num_channels,
const guint8 *pixel)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_DRAWABLE, drawable,
G_TYPE_INT, x_coord,
G_TYPE_INT, y_coord,
G_TYPE_INT, num_channels,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 4), pixel, num_channels);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-drawable-set-pixel",
args);
gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
/** /**
* gimp_drawable_fill: * gimp_drawable_fill:
* @drawable: The drawable. * @drawable: The drawable.
@ -923,8 +822,7 @@ gimp_drawable_offset (GimpDrawable *drawable,
* @actual_width: (out): The previews width. * @actual_width: (out): The previews width.
* @actual_height: (out): The previews height. * @actual_height: (out): The previews height.
* @bpp: (out): The previews bpp. * @bpp: (out): The previews bpp.
* @thumbnail_data_count: (out): The number of bytes in thumbnail data. * @thumbnail_data: (out) (transfer full): The thumbnail data.
* @thumbnail_data: (out) (array length=thumbnail_data_count) (element-type guint8) (transfer full): The thumbnail data.
* *
* Get a thumbnail of a drawable. * Get a thumbnail of a drawable.
* *
@ -942,8 +840,7 @@ _gimp_drawable_thumbnail (GimpDrawable *drawable,
gint *actual_width, gint *actual_width,
gint *actual_height, gint *actual_height,
gint *bpp, gint *bpp,
gint *thumbnail_data_count, GBytes **thumbnail_data)
guint8 **thumbnail_data)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -963,7 +860,6 @@ _gimp_drawable_thumbnail (GimpDrawable *drawable,
*actual_width = 0; *actual_width = 0;
*actual_height = 0; *actual_height = 0;
*bpp = 0; *bpp = 0;
*thumbnail_data_count = 0;
*thumbnail_data = NULL; *thumbnail_data = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
@ -973,8 +869,7 @@ _gimp_drawable_thumbnail (GimpDrawable *drawable,
*actual_width = GIMP_VALUES_GET_INT (return_vals, 1); *actual_width = GIMP_VALUES_GET_INT (return_vals, 1);
*actual_height = GIMP_VALUES_GET_INT (return_vals, 2); *actual_height = GIMP_VALUES_GET_INT (return_vals, 2);
*bpp = GIMP_VALUES_GET_INT (return_vals, 3); *bpp = GIMP_VALUES_GET_INT (return_vals, 3);
*thumbnail_data_count = GIMP_VALUES_GET_INT (return_vals, 4); *thumbnail_data = GIMP_VALUES_DUP_BYTES (return_vals, 4);
*thumbnail_data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 5);
} }
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
@ -994,8 +889,7 @@ _gimp_drawable_thumbnail (GimpDrawable *drawable,
* @width: (out): The previews width. * @width: (out): The previews width.
* @height: (out): The previews height. * @height: (out): The previews height.
* @bpp: (out): The previews bpp. * @bpp: (out): The previews bpp.
* @thumbnail_data_count: (out): The number of bytes in thumbnail data. * @thumbnail_data: (out) (transfer full): The thumbnail data.
* @thumbnail_data: (out) (array length=thumbnail_data_count) (element-type guint8) (transfer full): The thumbnail data.
* *
* Get a thumbnail of a sub-area of a drawable drawable. * Get a thumbnail of a sub-area of a drawable drawable.
* *
@ -1019,8 +913,7 @@ _gimp_drawable_sub_thumbnail (GimpDrawable *drawable,
gint *width, gint *width,
gint *height, gint *height,
gint *bpp, gint *bpp,
gint *thumbnail_data_count, GBytes **thumbnail_data)
guint8 **thumbnail_data)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -1044,7 +937,6 @@ _gimp_drawable_sub_thumbnail (GimpDrawable *drawable,
*width = 0; *width = 0;
*height = 0; *height = 0;
*bpp = 0; *bpp = 0;
*thumbnail_data_count = 0;
*thumbnail_data = NULL; *thumbnail_data = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
@ -1054,8 +946,7 @@ _gimp_drawable_sub_thumbnail (GimpDrawable *drawable,
*width = GIMP_VALUES_GET_INT (return_vals, 1); *width = GIMP_VALUES_GET_INT (return_vals, 1);
*height = GIMP_VALUES_GET_INT (return_vals, 2); *height = GIMP_VALUES_GET_INT (return_vals, 2);
*bpp = GIMP_VALUES_GET_INT (return_vals, 3); *bpp = GIMP_VALUES_GET_INT (return_vals, 3);
*thumbnail_data_count = GIMP_VALUES_GET_INT (return_vals, 4); *thumbnail_data = GIMP_VALUES_DUP_BYTES (return_vals, 4);
*thumbnail_data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 5);
} }
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View File

@ -64,15 +64,6 @@ gboolean gimp_drawable_update (GimpDrawable
gint y, gint y,
gint width, gint width,
gint height); gint height);
guint8* gimp_drawable_get_pixel (GimpDrawable *drawable,
gint x_coord,
gint y_coord,
gint *num_channels);
gboolean gimp_drawable_set_pixel (GimpDrawable *drawable,
gint x_coord,
gint y_coord,
gint num_channels,
const guint8 *pixel);
gboolean gimp_drawable_fill (GimpDrawable *drawable, gboolean gimp_drawable_fill (GimpDrawable *drawable,
GimpFillType fill_type); GimpFillType fill_type);
gboolean gimp_drawable_offset (GimpDrawable *drawable, gboolean gimp_drawable_offset (GimpDrawable *drawable,
@ -86,8 +77,7 @@ G_GNUC_INTERNAL gboolean _gimp_drawable_thumbnail (GimpDrawable
gint *actual_width, gint *actual_width,
gint *actual_height, gint *actual_height,
gint *bpp, gint *bpp,
gint *thumbnail_data_count, GBytes **thumbnail_data);
guint8 **thumbnail_data);
G_GNUC_INTERNAL gboolean _gimp_drawable_sub_thumbnail (GimpDrawable *drawable, G_GNUC_INTERNAL gboolean _gimp_drawable_sub_thumbnail (GimpDrawable *drawable,
gint src_x, gint src_x,
gint src_y, gint src_y,
@ -98,8 +88,7 @@ G_GNUC_INTERNAL gboolean _gimp_drawable_sub_thumbnail (GimpDrawable
gint *width, gint *width,
gint *height, gint *height,
gint *bpp, gint *bpp,
gint *thumbnail_data_count, GBytes **thumbnail_data);
guint8 **thumbnail_data);
gboolean gimp_drawable_foreground_extract (GimpDrawable *drawable, gboolean gimp_drawable_foreground_extract (GimpDrawable *drawable,
GimpForegroundExtractMode mode, GimpForegroundExtractMode mode,
GimpDrawable *mask); GimpDrawable *mask);

View File

@ -266,8 +266,9 @@ static void
gimp_drawable_preview_draw_original (GimpPreview *preview) gimp_drawable_preview_draw_original (GimpPreview *preview)
{ {
GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview); GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview);
guchar *buffer; GBytes *buffer;
gint width, height; gint width, height;
gint tn_width, tn_height;
gint xoff, yoff; gint xoff, yoff;
gint xmin, ymin; gint xmin, ymin;
gint xmax, ymax; gint xmax, ymax;
@ -290,7 +291,8 @@ gimp_drawable_preview_draw_original (GimpPreview *preview)
xoff + xmin, xoff + xmin,
yoff + ymin, yoff + ymin,
width, height, width, height,
&width, &height, &bpp); width, height,
&tn_width, &tn_height, &bpp);
switch (bpp) switch (bpp)
{ {
@ -299,13 +301,14 @@ gimp_drawable_preview_draw_original (GimpPreview *preview)
case 3: type = GIMP_RGB_IMAGE; break; case 3: type = GIMP_RGB_IMAGE; break;
case 4: type = GIMP_RGBA_IMAGE; break; case 4: type = GIMP_RGBA_IMAGE; break;
default: default:
g_free (buffer); g_bytes_unref (buffer);
return; return;
} }
gimp_preview_area_draw (GIMP_PREVIEW_AREA (gimp_preview_get_area (preview)), gimp_preview_area_draw (GIMP_PREVIEW_AREA (gimp_preview_get_area (preview)),
0, 0, width, height, type, buffer, width * bpp); 0, 0, tn_width, tn_height, type,
g_free (buffer); g_bytes_get_data (buffer, NULL), width * bpp);
g_bytes_unref (buffer);
} }
static void static void
@ -327,11 +330,12 @@ _gimp_drawable_preview_area_draw_thumb (GimpPreviewArea *area,
gint width, gint width,
gint height) gint height)
{ {
guchar *buffer; GBytes *buffer;
gint x1, y1, x2, y2; gint x1, y1, x2, y2;
gint bpp; gint bpp;
gint size = 100; gint size = 100;
gint nav_width, nav_height; gint nav_width, nav_height;
gint tn_width, tn_height;
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area)); g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
g_return_if_fail (gimp_item_is_valid (GIMP_ITEM (drawable))); g_return_if_fail (gimp_item_is_valid (GIMP_ITEM (drawable)));
@ -363,13 +367,15 @@ _gimp_drawable_preview_area_draw_thumb (GimpPreviewArea *area,
{ {
buffer = gimp_drawable_get_sub_thumbnail_data (drawable, buffer = gimp_drawable_get_sub_thumbnail_data (drawable,
x1, y1, x2 - x1, y2 - y1, x1, y1, x2 - x1, y2 - y1,
&nav_width, &nav_height, nav_width, nav_height,
&tn_width, &tn_height,
&bpp); &bpp);
} }
else else
{ {
buffer = gimp_drawable_get_thumbnail_data (drawable, buffer = gimp_drawable_get_thumbnail_data (drawable,
&nav_width, &nav_height, nav_width, nav_height,
&tn_width, &tn_height,
&bpp); &bpp);
} }
@ -377,7 +383,7 @@ _gimp_drawable_preview_area_draw_thumb (GimpPreviewArea *area,
{ {
GimpImageType type; GimpImageType type;
gtk_widget_set_size_request (GTK_WIDGET (area), nav_width, nav_height); gtk_widget_set_size_request (GTK_WIDGET (area), tn_width, tn_height);
gtk_widget_show (GTK_WIDGET (area)); gtk_widget_show (GTK_WIDGET (area));
gtk_widget_realize (GTK_WIDGET (area)); gtk_widget_realize (GTK_WIDGET (area));
@ -388,14 +394,15 @@ _gimp_drawable_preview_area_draw_thumb (GimpPreviewArea *area,
case 3: type = GIMP_RGB_IMAGE; break; case 3: type = GIMP_RGB_IMAGE; break;
case 4: type = GIMP_RGBA_IMAGE; break; case 4: type = GIMP_RGBA_IMAGE; break;
default: default:
g_free (buffer); g_bytes_unref (buffer);
return; return;
} }
gimp_preview_area_draw (area, gimp_preview_area_draw (area,
0, 0, nav_width, nav_height, 0, 0, tn_width, tn_height,
type, buffer, bpp * nav_width); type,
g_free (buffer); g_bytes_get_data (buffer, NULL), bpp * tn_width);
g_bytes_unref (buffer);
} }
} }
@ -451,22 +458,17 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
{ {
GimpImageType type; GimpImageType type;
GimpSelection *selection; GimpSelection *selection;
guchar *src; GBytes *src;
guchar *sel; GBytes *sel;
gint d_w, d_h, d_bpp; gint d_w, d_h, d_bpp;
gint s_w, s_h, s_bpp; gint s_w, s_h, s_bpp;
d_w = draw_width;
d_h = draw_height;
s_w = draw_width;
s_h = draw_height;
selection = gimp_image_get_selection (image); selection = gimp_image_get_selection (image);
src = gimp_drawable_get_sub_thumbnail_data (priv->drawable, src = gimp_drawable_get_sub_thumbnail_data (priv->drawable,
draw_x, draw_y, draw_x, draw_y,
draw_width, draw_height, draw_width, draw_height,
draw_width, draw_height,
&d_w, &d_h, &d_w, &d_h,
&d_bpp); &d_bpp);
@ -474,6 +476,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
draw_x + offset_x, draw_x + offset_x,
draw_y + offset_y, draw_y + offset_y,
draw_width, draw_height, draw_width, draw_height,
draw_width, draw_height,
&s_w, &s_h, &s_w, &s_h,
&s_bpp); &s_bpp);
@ -484,8 +487,8 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
case 3: type = GIMP_RGB_IMAGE; break; case 3: type = GIMP_RGB_IMAGE; break;
case 4: type = GIMP_RGBA_IMAGE; break; case 4: type = GIMP_RGBA_IMAGE; break;
default: default:
g_free (sel); g_bytes_unref (sel);
g_free (src); g_bytes_unref (src);
return; return;
} }
@ -495,15 +498,15 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview,
draw_width, draw_width,
draw_height, draw_height,
type, type,
src, draw_width * d_bpp, g_bytes_get_data (src, NULL), draw_width * d_bpp,
(buf + (buf +
(draw_x - x) * d_bpp + (draw_x - x) * d_bpp +
(draw_y - y) * d_w * d_bpp), (draw_y - y) * d_w * d_bpp),
rowstride, rowstride,
sel, s_w); g_bytes_get_data (sel, NULL), s_w);
g_free (sel); g_bytes_unref (sel);
g_free (src); g_bytes_unref (src);
} }
} }
} }
@ -548,7 +551,7 @@ gimp_drawable_preview_set_drawable (GimpDrawablePreview *drawable_preview,
guchar *cmap; guchar *cmap;
gint num_colors; gint num_colors;
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (area), gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (area),
cmap, num_colors); cmap, num_colors);
g_free (cmap); g_free (cmap);

View File

@ -1101,7 +1101,7 @@ gimp_export_image (GimpImage **image,
{ {
gint n_colors; gint n_colors;
g_free (gimp_image_get_colormap (*image, &n_colors)); g_free (gimp_image_get_colormap (*image, NULL, &n_colors));
if (n_colors > 2) if (n_colors > 2)
actions = g_slist_prepend (actions, actions = g_slist_prepend (actions,

View File

@ -41,9 +41,6 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
if (! strcmp (param_def->type_name, "GimpParamInt32Array")) if (! strcmp (param_def->type_name, "GimpParamInt32Array"))
return gimp_param_spec_int32_array (name, nick, blurb, flags); return gimp_param_spec_int32_array (name, nick, blurb, flags);
if (! strcmp (param_def->type_name, "GimpParamUInt8Array"))
return gimp_param_spec_uint8_array (name, nick, blurb, flags);
if (! strcmp (param_def->type_name, "GimpParamFloatArray")) if (! strcmp (param_def->type_name, "GimpParamFloatArray"))
return gimp_param_spec_float_array (name, nick, blurb, flags); return gimp_param_spec_float_array (name, nick, blurb, flags);
@ -71,6 +68,10 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
! strcmp (param_def->value_type_name, "GStrv")) ! strcmp (param_def->value_type_name, "GStrv"))
return g_param_spec_boxed (name, nick, blurb, G_TYPE_STRV, flags); return g_param_spec_boxed (name, nick, blurb, G_TYPE_STRV, flags);
if (! strcmp (param_def->type_name, "GParamBoxed") &&
! strcmp (param_def->value_type_name, "GBytes"))
return g_param_spec_boxed (name, nick, blurb, G_TYPE_BYTES, flags);
break; break;
case GP_PARAM_DEF_TYPE_INT: case GP_PARAM_DEF_TYPE_INT:
@ -647,6 +648,10 @@ gimp_gp_param_to_value (gpointer gimp,
{ {
g_value_set_boxed (value, param->data.d_strv); g_value_set_boxed (value, param->data.d_strv);
} }
else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
{
g_value_set_boxed (value, param->data.d_bytes);
}
else if (G_VALUE_TYPE (value) == G_TYPE_FILE) else if (G_VALUE_TYPE (value) == G_TYPE_FILE)
{ {
g_value_take_object (value, (param->data.d_string ? g_value_take_object (value, (param->data.d_string ?
@ -668,13 +673,6 @@ gimp_gp_param_to_value (gpointer gimp,
param->data.d_array.size / param->data.d_array.size /
sizeof (gint32)); sizeof (gint32));
} }
else if (GIMP_VALUE_HOLDS_UINT8_ARRAY (value))
{
gimp_value_set_uint8_array (value,
param->data.d_array.data,
param->data.d_array.size /
sizeof (guint8));
}
else if (GIMP_VALUE_HOLDS_FLOAT_ARRAY (value)) else if (GIMP_VALUE_HOLDS_FLOAT_ARRAY (value))
{ {
gimp_value_set_float_array (value, gimp_value_set_float_array (value,
@ -955,7 +953,6 @@ gimp_value_to_gp_param (const GValue *value,
} }
} }
else if (GIMP_VALUE_HOLDS_INT32_ARRAY (value) || else if (GIMP_VALUE_HOLDS_INT32_ARRAY (value) ||
GIMP_VALUE_HOLDS_UINT8_ARRAY (value) ||
GIMP_VALUE_HOLDS_FLOAT_ARRAY (value) || GIMP_VALUE_HOLDS_FLOAT_ARRAY (value) ||
GIMP_VALUE_HOLDS_RGB_ARRAY (value)) GIMP_VALUE_HOLDS_RGB_ARRAY (value))
{ {
@ -979,6 +976,22 @@ gimp_value_to_gp_param (const GValue *value,
param->data.d_array.data = NULL; param->data.d_array.data = NULL;
} }
} }
else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
{
GBytes *bytes = g_value_get_boxed (value);
param->param_type = GP_PARAM_TYPE_BYTES;
if (bytes != NULL)
{
if (full_copy)
param->data.d_bytes = g_bytes_new (g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
else
param->data.d_bytes = g_bytes_new_static (g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
}
}
else if (G_VALUE_HOLDS (value, G_TYPE_STRV)) else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
{ {
gchar **array = g_value_get_boxed (value); gchar **array = g_value_get_boxed (value);
@ -1169,6 +1182,10 @@ _gimp_gp_params_free (GPParam *params,
g_strfreev (params[i].data.d_strv); g_strfreev (params[i].data.d_strv);
break; break;
case GP_PARAM_TYPE_BYTES:
g_bytes_unref (params[i].data.d_bytes);
break;
case GP_PARAM_TYPE_ID_ARRAY: case GP_PARAM_TYPE_ID_ARRAY:
if (full_copy) if (full_copy)
g_free (params[i].data.d_id_array.type_name); g_free (params[i].data.d_id_array.type_name);

View File

@ -566,7 +566,8 @@ gimp_image_list_selected_drawables (GimpImage *image)
/** /**
* gimp_image_get_colormap: * gimp_image_get_colormap:
* @image: The image. * @image: The image.
* @num_colors: (out): Returns the number of colors in the colormap array. * @colormap_len: (out) (optional): The size (in bytes) of the returned colormap
* @num_colors: (out) (optional): Returns the number of colors in the colormap array.
* *
* Returns the image's colormap * Returns the image's colormap
* *
@ -574,17 +575,22 @@ gimp_image_list_selected_drawables (GimpImage *image)
* well as the number of colors contained in the colormap. If the image * well as the number of colors contained in the colormap. If the image
* is not of base type INDEXED, this pointer will be NULL. * is not of base type INDEXED, this pointer will be NULL.
* *
* Returns: (array): The image's colormap. * Returns: (array length=colormap_len): The image's colormap.
*/ */
guchar * guchar *
gimp_image_get_colormap (GimpImage *image, gimp_image_get_colormap (GimpImage *image,
gint *colormap_len,
gint *num_colors) gint *num_colors)
{ {
gint num_bytes; GBytes *bytes;
gsize num_bytes;
guchar *cmap; guchar *cmap;
cmap = _gimp_image_get_colormap (image, &num_bytes); bytes = _gimp_image_get_colormap (image);
cmap = g_bytes_unref_to_data (bytes, &num_bytes);
if (colormap_len)
*colormap_len = num_bytes;
if (num_colors) if (num_colors)
*num_colors = num_bytes / 3; *num_colors = num_bytes / 3;
@ -611,7 +617,14 @@ gimp_image_set_colormap (GimpImage *image,
const guchar *colormap, const guchar *colormap,
gint num_colors) gint num_colors)
{ {
return _gimp_image_set_colormap (image, num_colors * 3, colormap); GBytes *bytes;
gboolean ret;
bytes = g_bytes_new_static (colormap, num_colors * 3);
ret = _gimp_image_set_colormap (image, bytes);
g_bytes_unref (bytes);
return ret;
} }
/** /**
@ -638,8 +651,9 @@ gimp_image_get_thumbnail_data (GimpImage *image,
{ {
gint ret_width; gint ret_width;
gint ret_height; gint ret_height;
GBytes *image_bytes;
guchar *image_data; guchar *image_data;
gint data_size; gsize data_size;
_gimp_image_thumbnail (image, _gimp_image_thumbnail (image,
*width, *width,
@ -647,8 +661,8 @@ gimp_image_get_thumbnail_data (GimpImage *image,
&ret_width, &ret_width,
&ret_height, &ret_height,
bpp, bpp,
&data_size, &image_bytes);
&image_data); image_data = g_bytes_unref_to_data (image_bytes, &data_size);
*width = ret_width; *width = ret_width;
*height = ret_height; *height = ret_height;

View File

@ -59,6 +59,7 @@ gboolean gimp_image_take_selected_vectors (GimpImage *image,
GList * gimp_image_list_selected_drawables(GimpImage *image); GList * gimp_image_list_selected_drawables(GimpImage *image);
guchar * gimp_image_get_colormap (GimpImage *image, guchar * gimp_image_get_colormap (GimpImage *image,
gint *colormap_len,
gint *num_colors); gint *num_colors);
gboolean gimp_image_set_colormap (GimpImage *image, gboolean gimp_image_set_colormap (GimpImage *image,
const guchar *colormap, const guchar *colormap,

View File

@ -1746,7 +1746,6 @@ gimp_image_merge_layer_group (GimpImage *image,
/** /**
* _gimp_image_get_colormap: * _gimp_image_get_colormap:
* @image: The image. * @image: The image.
* @num_bytes: (out): Number of bytes in the colormap array.
* *
* Returns the image's colormap * Returns the image's colormap
* *
@ -1756,17 +1755,14 @@ gimp_image_merge_layer_group (GimpImage *image,
* 3. If the image is not in Indexed color mode, no colormap is * 3. If the image is not in Indexed color mode, no colormap is
* returned. * returned.
* *
* Returns: (array length=num_bytes) (element-type guint8) (transfer full): * Returns: (transfer full): The image's colormap.
* The image's colormap.
* The returned value must be freed with g_free().
**/ **/
guint8 * GBytes *
_gimp_image_get_colormap (GimpImage *image, _gimp_image_get_colormap (GimpImage *image)
gint *num_bytes)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
guint8 *colormap = NULL; GBytes *colormap = NULL;
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
@ -1777,13 +1773,8 @@ _gimp_image_get_colormap (GimpImage *image,
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
*num_bytes = 0;
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{ colormap = GIMP_VALUES_DUP_BYTES (return_vals, 1);
*num_bytes = GIMP_VALUES_GET_INT (return_vals, 1);
colormap = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
@ -1793,8 +1784,7 @@ _gimp_image_get_colormap (GimpImage *image,
/** /**
* _gimp_image_set_colormap: * _gimp_image_set_colormap:
* @image: The image. * @image: The image.
* @num_bytes: Number of bytes in the colormap array. * @colormap: The new colormap values.
* @colormap: (array length=num_bytes) (element-type guint8): The new colormap values.
* *
* Sets the entries in the image's colormap. * Sets the entries in the image's colormap.
* *
@ -1807,9 +1797,8 @@ _gimp_image_get_colormap (GimpImage *image,
* Returns: TRUE on success. * Returns: TRUE on success.
**/ **/
gboolean gboolean
_gimp_image_set_colormap (GimpImage *image, _gimp_image_set_colormap (GimpImage *image,
gint num_bytes, GBytes *colormap)
const guint8 *colormap)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -1817,10 +1806,8 @@ _gimp_image_set_colormap (GimpImage *image,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
G_TYPE_INT, num_bytes, G_TYPE_BYTES, colormap,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 2), colormap, num_bytes);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-set-colormap", "gimp-image-set-colormap",
@ -1988,8 +1975,7 @@ gimp_image_is_dirty (GimpImage *image)
* @actual_width: (out): The previews width. * @actual_width: (out): The previews width.
* @actual_height: (out): The previews height. * @actual_height: (out): The previews height.
* @bpp: (out): The previews bpp. * @bpp: (out): The previews bpp.
* @thumbnail_data_count: (out): The number of bytes in thumbnail data. * @thumbnail_data: (out) (transfer full): The thumbnail data.
* @thumbnail_data: (out) (array length=thumbnail_data_count) (element-type guint8) (transfer full): The thumbnail data.
* *
* Get a thumbnail of an image. * Get a thumbnail of an image.
* *
@ -2007,8 +1993,7 @@ _gimp_image_thumbnail (GimpImage *image,
gint *actual_width, gint *actual_width,
gint *actual_height, gint *actual_height,
gint *bpp, gint *bpp,
gint *thumbnail_data_count, GBytes **thumbnail_data)
guint8 **thumbnail_data)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -2028,7 +2013,6 @@ _gimp_image_thumbnail (GimpImage *image,
*actual_width = 0; *actual_width = 0;
*actual_height = 0; *actual_height = 0;
*bpp = 0; *bpp = 0;
*thumbnail_data_count = 0;
*thumbnail_data = NULL; *thumbnail_data = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
@ -2038,8 +2022,7 @@ _gimp_image_thumbnail (GimpImage *image,
*actual_width = GIMP_VALUES_GET_INT (return_vals, 1); *actual_width = GIMP_VALUES_GET_INT (return_vals, 1);
*actual_height = GIMP_VALUES_GET_INT (return_vals, 2); *actual_height = GIMP_VALUES_GET_INT (return_vals, 2);
*bpp = GIMP_VALUES_GET_INT (return_vals, 3); *bpp = GIMP_VALUES_GET_INT (return_vals, 3);
*thumbnail_data_count = GIMP_VALUES_GET_INT (return_vals, 4); *thumbnail_data = GIMP_VALUES_DUP_BYTES (return_vals, 4);
*thumbnail_data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 5);
} }
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View File

@ -115,11 +115,9 @@ GimpLayer* gimp_image_merge_down (GimpImage
GimpMergeType merge_type); GimpMergeType merge_type);
GimpLayer* gimp_image_merge_layer_group (GimpImage *image, GimpLayer* gimp_image_merge_layer_group (GimpImage *image,
GimpLayer *layer_group); GimpLayer *layer_group);
G_GNUC_INTERNAL guint8* _gimp_image_get_colormap (GimpImage *image, G_GNUC_INTERNAL GBytes* _gimp_image_get_colormap (GimpImage *image);
gint *num_bytes);
G_GNUC_INTERNAL gboolean _gimp_image_set_colormap (GimpImage *image, G_GNUC_INTERNAL gboolean _gimp_image_set_colormap (GimpImage *image,
gint num_bytes, GBytes *colormap);
const guint8 *colormap);
G_GNUC_INTERNAL gchar* _gimp_image_get_metadata (GimpImage *image); G_GNUC_INTERNAL gchar* _gimp_image_get_metadata (GimpImage *image);
G_GNUC_INTERNAL gboolean _gimp_image_set_metadata (GimpImage *image, G_GNUC_INTERNAL gboolean _gimp_image_set_metadata (GimpImage *image,
const gchar *metadata_string); const gchar *metadata_string);
@ -131,8 +129,7 @@ G_GNUC_INTERNAL gboolean _gimp_image_thumbnail (GimpImage
gint *actual_width, gint *actual_width,
gint *actual_height, gint *actual_height,
gint *bpp, gint *bpp,
gint *thumbnail_data_count, GBytes **thumbnail_data);
guint8 **thumbnail_data);
GimpLayer** gimp_image_get_selected_layers (GimpImage *image, GimpLayer** gimp_image_get_selected_layers (GimpImage *image,
gint *num_layers); gint *num_layers);
gboolean gimp_image_set_selected_layers (GimpImage *image, gboolean gimp_image_set_selected_layers (GimpImage *image,

View File

@ -40,17 +40,17 @@
GimpColorProfile * GimpColorProfile *
gimp_image_get_color_profile (GimpImage *image) gimp_image_get_color_profile (GimpImage *image)
{ {
guint8 *data; GBytes *data;
gint length;
data = _gimp_image_get_color_profile (image, &length);
data = _gimp_image_get_color_profile (image);
if (data) if (data)
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (data, length, NULL); profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (data, NULL),
g_free (data); g_bytes_get_size (data),
NULL);
g_bytes_unref (data);
return profile; return profile;
} }
@ -61,7 +61,7 @@ gimp_image_get_color_profile (GimpImage *image)
/** /**
* gimp_image_set_color_profile: * gimp_image_set_color_profile:
* @image: The image. * @image: The image.
* @profile: A #GimpColorProfile, or %NULL. * @profile: (nullable): A #GimpColorProfile, or %NULL.
* *
* Sets the image's color profile * Sets the image's color profile
* *
@ -76,7 +76,8 @@ gimp_image_set_color_profile (GimpImage *image,
GimpColorProfile *profile) GimpColorProfile *profile)
{ {
const guint8 *data = NULL; const guint8 *data = NULL;
gint length = 0; GBytes *bytes = NULL;
gboolean ret;
g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile), g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
FALSE); FALSE);
@ -86,10 +87,13 @@ gimp_image_set_color_profile (GimpImage *image,
gsize l; gsize l;
data = gimp_color_profile_get_icc_profile (profile, &l); data = gimp_color_profile_get_icc_profile (profile, &l);
length = l; bytes = g_bytes_new_static (data, l);
} }
return _gimp_image_set_color_profile (image, length, data); ret = _gimp_image_set_color_profile (image, bytes);
g_bytes_unref (bytes);
return ret;
} }
/** /**
@ -109,17 +113,17 @@ gimp_image_set_color_profile (GimpImage *image,
GimpColorProfile * GimpColorProfile *
gimp_image_get_simulation_profile (GimpImage *image) gimp_image_get_simulation_profile (GimpImage *image)
{ {
guint8 *data; GBytes *data;
gint length;
data = _gimp_image_get_simulation_profile (image, &length);
data = _gimp_image_get_simulation_profile (image);
if (data) if (data)
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (data, length, NULL); profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (data, NULL),
g_free (data); g_bytes_get_size (data),
NULL);
g_bytes_unref (data);
return profile; return profile;
} }
@ -145,7 +149,8 @@ gimp_image_set_simulation_profile (GimpImage *image,
GimpColorProfile *profile) GimpColorProfile *profile)
{ {
const guint8 *data = NULL; const guint8 *data = NULL;
gint length = 0; GBytes *bytes = NULL;
gboolean ret;
g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile), g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
FALSE); FALSE);
@ -155,10 +160,12 @@ gimp_image_set_simulation_profile (GimpImage *image,
gsize l; gsize l;
data = gimp_color_profile_get_icc_profile (profile, &l); data = gimp_color_profile_get_icc_profile (profile, &l);
length = l; bytes = g_bytes_new_static (data, l);
} }
return _gimp_image_set_simulation_profile (image, length, data); ret = _gimp_image_set_simulation_profile (image, bytes);
g_bytes_unref (bytes);
return ret;
} }
/** /**
@ -182,17 +189,18 @@ gimp_image_set_simulation_profile (GimpImage *image,
GimpColorProfile * GimpColorProfile *
gimp_image_get_effective_color_profile (GimpImage *image) gimp_image_get_effective_color_profile (GimpImage *image)
{ {
guint8 *data; GBytes *data;
gint length;
data = _gimp_image_get_effective_color_profile (image, &length); data = _gimp_image_get_effective_color_profile (image);
if (data) if (data)
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (data, length, NULL); profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (data, NULL),
g_free (data); g_bytes_get_size (data),
NULL);
g_bytes_unref (data);
return profile; return profile;
} }
@ -224,7 +232,8 @@ gimp_image_convert_color_profile (GimpImage *image,
gboolean bpc) gboolean bpc)
{ {
const guint8 *data = NULL; const guint8 *data = NULL;
gint length = 0; GBytes *bytes = NULL;
gboolean ret;
g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile), g_return_val_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile),
FALSE); FALSE);
@ -234,9 +243,10 @@ gimp_image_convert_color_profile (GimpImage *image,
gsize l; gsize l;
data = gimp_color_profile_get_icc_profile (profile, &l); data = gimp_color_profile_get_icc_profile (profile, &l);
length = l; bytes = g_bytes_new_static (data, l);
} }
return _gimp_image_convert_color_profile (image, length, data, ret = _gimp_image_convert_color_profile (image, bytes, intent, bpc);
intent, bpc); g_bytes_unref (bytes);
return ret;
} }

View File

@ -39,26 +39,22 @@
/** /**
* _gimp_image_get_color_profile: * _gimp_image_get_color_profile:
* @image: The image. * @image: The image.
* @num_bytes: (out): Number of bytes in the color_profile array.
* *
* Returns the image's color profile * Returns the image's color profile
* *
* This procedure returns the image's color profile, or NULL if the * This procedure returns the image's color profile, or NULL if the
* image has no color profile assigned. * image has no color profile assigned.
* *
* Returns: (array length=num_bytes) (element-type guint8) (transfer full): * Returns: (transfer full): The image's serialized color profile.
* The image's serialized color profile.
* The returned value must be freed with g_free().
* *
* Since: 2.10 * Since: 2.10
**/ **/
guint8 * GBytes *
_gimp_image_get_color_profile (GimpImage *image, _gimp_image_get_color_profile (GimpImage *image)
gint *num_bytes)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
guint8 *profile_data = NULL; GBytes *profile_data = NULL;
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
@ -69,13 +65,8 @@ _gimp_image_get_color_profile (GimpImage *image,
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
*num_bytes = 0;
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{ profile_data = GIMP_VALUES_DUP_BYTES (return_vals, 1);
*num_bytes = GIMP_VALUES_GET_INT (return_vals, 1);
profile_data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
@ -85,7 +76,6 @@ _gimp_image_get_color_profile (GimpImage *image,
/** /**
* _gimp_image_get_effective_color_profile: * _gimp_image_get_effective_color_profile:
* @image: The image. * @image: The image.
* @num_bytes: (out): Number of bytes in the color_profile array.
* *
* Returns the color profile that is used for the image * Returns the color profile that is used for the image
* *
@ -95,19 +85,16 @@ _gimp_image_get_color_profile (GimpImage *image,
* or a generated default RGB or grayscale profile, according to the * or a generated default RGB or grayscale profile, according to the
* image's type. * image's type.
* *
* Returns: (array length=num_bytes) (element-type guint8) (transfer full): * Returns: (transfer full): The image's serialized color profile.
* The image's serialized color profile.
* The returned value must be freed with g_free().
* *
* Since: 2.10 * Since: 2.10
**/ **/
guint8 * GBytes *
_gimp_image_get_effective_color_profile (GimpImage *image, _gimp_image_get_effective_color_profile (GimpImage *image)
gint *num_bytes)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
guint8 *profile_data = NULL; GBytes *profile_data = NULL;
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
@ -118,13 +105,8 @@ _gimp_image_get_effective_color_profile (GimpImage *image,
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
*num_bytes = 0;
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{ profile_data = GIMP_VALUES_DUP_BYTES (return_vals, 1);
*num_bytes = GIMP_VALUES_GET_INT (return_vals, 1);
profile_data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
@ -134,8 +116,7 @@ _gimp_image_get_effective_color_profile (GimpImage *image,
/** /**
* _gimp_image_set_color_profile: * _gimp_image_set_color_profile:
* @image: The image. * @image: The image.
* @num_bytes: Number of bytes in the color_profile array. * @color_profile: The new serialized color profile.
* @color_profile: (array length=num_bytes) (element-type guint8): The new serialized color profile.
* *
* Sets the image's color profile * Sets the image's color profile
* *
@ -150,9 +131,8 @@ _gimp_image_get_effective_color_profile (GimpImage *image,
* Since: 2.10 * Since: 2.10
**/ **/
gboolean gboolean
_gimp_image_set_color_profile (GimpImage *image, _gimp_image_set_color_profile (GimpImage *image,
gint num_bytes, GBytes *color_profile)
const guint8 *color_profile)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -160,10 +140,8 @@ _gimp_image_set_color_profile (GimpImage *image,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
G_TYPE_INT, num_bytes, G_TYPE_BYTES, color_profile,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 2), color_profile, num_bytes);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-set-color-profile", "gimp-image-set-color-profile",
@ -223,26 +201,22 @@ gimp_image_set_color_profile_from_file (GimpImage *image,
/** /**
* _gimp_image_get_simulation_profile: * _gimp_image_get_simulation_profile:
* @image: The image. * @image: The image.
* @num_bytes: (out): Number of bytes in the color_profile array.
* *
* Returns the image's simulation color profile * Returns the image's simulation color profile
* *
* This procedure returns the image's simulation color profile, or NULL * This procedure returns the image's simulation color profile, or NULL
* if the image has no simulation color profile assigned. * if the image has no simulation color profile assigned.
* *
* Returns: (array length=num_bytes) (element-type guint8) (transfer full): * Returns: (transfer full): The image's serialized simulation color profile.
* The image's serialized simulation color profile.
* The returned value must be freed with g_free().
* *
* Since: 3.0 * Since: 3.0
**/ **/
guint8 * GBytes *
_gimp_image_get_simulation_profile (GimpImage *image, _gimp_image_get_simulation_profile (GimpImage *image)
gint *num_bytes)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
guint8 *profile_data = NULL; GBytes *profile_data = NULL;
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
@ -253,13 +227,8 @@ _gimp_image_get_simulation_profile (GimpImage *image,
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
*num_bytes = 0;
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{ profile_data = GIMP_VALUES_DUP_BYTES (return_vals, 1);
*num_bytes = GIMP_VALUES_GET_INT (return_vals, 1);
profile_data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
@ -269,8 +238,7 @@ _gimp_image_get_simulation_profile (GimpImage *image,
/** /**
* _gimp_image_set_simulation_profile: * _gimp_image_set_simulation_profile:
* @image: The image. * @image: The image.
* @num_bytes: Number of bytes in the color_profile array. * @color_profile: The new serialized simulation color profile.
* @color_profile: (array length=num_bytes) (element-type guint8): The new serialized simulation color profile.
* *
* Sets the image's simulation color profile * Sets the image's simulation color profile
* *
@ -283,9 +251,8 @@ _gimp_image_get_simulation_profile (GimpImage *image,
* Since: 3.0 * Since: 3.0
**/ **/
gboolean gboolean
_gimp_image_set_simulation_profile (GimpImage *image, _gimp_image_set_simulation_profile (GimpImage *image,
gint num_bytes, GBytes *color_profile)
const guint8 *color_profile)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -293,10 +260,8 @@ _gimp_image_set_simulation_profile (GimpImage *image,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
G_TYPE_INT, num_bytes, G_TYPE_BYTES, color_profile,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 2), color_profile, num_bytes);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-set-simulation-profile", "gimp-image-set-simulation-profile",
@ -505,8 +470,7 @@ gimp_image_set_simulation_bpc (GimpImage *image,
/** /**
* _gimp_image_convert_color_profile: * _gimp_image_convert_color_profile:
* @image: The image. * @image: The image.
* @num_bytes: Number of bytes in the color_profile array. * @color_profile: The serialized color profile.
* @color_profile: (array length=num_bytes) (element-type guint8): The serialized color profile.
* @intent: Rendering intent. * @intent: Rendering intent.
* @bpc: Black point compensation. * @bpc: Black point compensation.
* *
@ -523,8 +487,7 @@ gimp_image_set_simulation_bpc (GimpImage *image,
**/ **/
gboolean gboolean
_gimp_image_convert_color_profile (GimpImage *image, _gimp_image_convert_color_profile (GimpImage *image,
gint num_bytes, GBytes *color_profile,
const guint8 *color_profile,
GimpColorRenderingIntent intent, GimpColorRenderingIntent intent,
gboolean bpc) gboolean bpc)
{ {
@ -534,12 +497,10 @@ _gimp_image_convert_color_profile (GimpImage *image,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image, GIMP_TYPE_IMAGE, image,
G_TYPE_INT, num_bytes, G_TYPE_BYTES, color_profile,
GIMP_TYPE_UINT8_ARRAY, NULL,
GIMP_TYPE_COLOR_RENDERING_INTENT, intent, GIMP_TYPE_COLOR_RENDERING_INTENT, intent,
G_TYPE_BOOLEAN, bpc, G_TYPE_BOOLEAN, bpc,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 2), color_profile, num_bytes);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-convert-color-profile", "gimp-image-convert-color-profile",

View File

@ -32,20 +32,15 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */ /* For information look into the C source or the html documentation */
G_GNUC_INTERNAL guint8* _gimp_image_get_color_profile (GimpImage *image, G_GNUC_INTERNAL GBytes* _gimp_image_get_color_profile (GimpImage *image);
gint *num_bytes); G_GNUC_INTERNAL GBytes* _gimp_image_get_effective_color_profile (GimpImage *image);
G_GNUC_INTERNAL guint8* _gimp_image_get_effective_color_profile (GimpImage *image,
gint *num_bytes);
G_GNUC_INTERNAL gboolean _gimp_image_set_color_profile (GimpImage *image, G_GNUC_INTERNAL gboolean _gimp_image_set_color_profile (GimpImage *image,
gint num_bytes, GBytes *color_profile);
const guint8 *color_profile);
gboolean gimp_image_set_color_profile_from_file (GimpImage *image, gboolean gimp_image_set_color_profile_from_file (GimpImage *image,
GFile *file); GFile *file);
G_GNUC_INTERNAL guint8* _gimp_image_get_simulation_profile (GimpImage *image, G_GNUC_INTERNAL GBytes* _gimp_image_get_simulation_profile (GimpImage *image);
gint *num_bytes);
G_GNUC_INTERNAL gboolean _gimp_image_set_simulation_profile (GimpImage *image, G_GNUC_INTERNAL gboolean _gimp_image_set_simulation_profile (GimpImage *image,
gint num_bytes, GBytes *color_profile);
const guint8 *color_profile);
gboolean gimp_image_set_simulation_profile_from_file (GimpImage *image, gboolean gimp_image_set_simulation_profile_from_file (GimpImage *image,
GFile *file); GFile *file);
GimpColorRenderingIntent gimp_image_get_simulation_intent (GimpImage *image); GimpColorRenderingIntent gimp_image_get_simulation_intent (GimpImage *image);
@ -55,8 +50,7 @@ gboolean gimp_image_get_simulation_bpc (GimpImage
gboolean gimp_image_set_simulation_bpc (GimpImage *image, gboolean gimp_image_set_simulation_bpc (GimpImage *image,
gboolean bpc); gboolean bpc);
G_GNUC_INTERNAL gboolean _gimp_image_convert_color_profile (GimpImage *image, G_GNUC_INTERNAL gboolean _gimp_image_convert_color_profile (GimpImage *image,
gint num_bytes, GBytes *color_profile,
const guint8 *color_profile,
GimpColorRenderingIntent intent, GimpColorRenderingIntent intent,
gboolean bpc); gboolean bpc);
gboolean gimp_image_convert_color_profile_from_file (GimpImage *image, gboolean gimp_image_convert_color_profile_from_file (GimpImage *image,

View File

@ -173,8 +173,7 @@ gimp_image_convert_indexed (GimpImage *image,
* gimp_image_convert_set_dither_matrix: * gimp_image_convert_set_dither_matrix:
* @width: Width of the matrix (0 to reset to default matrix). * @width: Width of the matrix (0 to reset to default matrix).
* @height: Height of the matrix (0 to reset to default matrix). * @height: Height of the matrix (0 to reset to default matrix).
* @matrix_length: The length of 'matrix'. * @matrix: The matrix -- all values must be >= 1.
* @matrix: (array length=matrix_length) (element-type guint8): The matrix -- all values must be >= 1.
* *
* Set dither matrix for conversion to indexed * Set dither matrix for conversion to indexed
* *
@ -186,10 +185,9 @@ gimp_image_convert_indexed (GimpImage *image,
* Since: 2.4 * Since: 2.4
**/ **/
gboolean gboolean
gimp_image_convert_set_dither_matrix (gint width, gimp_image_convert_set_dither_matrix (gint width,
gint height, gint height,
gint matrix_length, GBytes *matrix)
const guint8 *matrix)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -198,10 +196,8 @@ gimp_image_convert_set_dither_matrix (gint width,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
G_TYPE_INT, width, G_TYPE_INT, width,
G_TYPE_INT, height, G_TYPE_INT, height,
G_TYPE_INT, matrix_length, G_TYPE_BYTES, matrix,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 3), matrix, matrix_length);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-convert-set-dither-matrix", "gimp-image-convert-set-dither-matrix",

View File

@ -43,8 +43,7 @@ gboolean gimp_image_convert_indexed (GimpImage *image,
const gchar *palette); const gchar *palette);
gboolean gimp_image_convert_set_dither_matrix (gint width, gboolean gimp_image_convert_set_dither_matrix (gint width,
gint height, gint height,
gint matrix_length, GBytes *matrix);
const guint8 *matrix);
gboolean gimp_image_convert_precision (GimpImage *image, gboolean gimp_image_convert_precision (GimpImage *image,
GimpPrecision precision); GimpPrecision precision);

View File

@ -95,8 +95,7 @@ gimp_pattern_get_info (GimpPattern *pattern,
* @width: (out): The pattern width. * @width: (out): The pattern width.
* @height: (out): The pattern height. * @height: (out): The pattern height.
* @bpp: (out): The pattern bpp. * @bpp: (out): The pattern bpp.
* @num_color_bytes: (out): Number of pattern bytes. * @color_bytes: (out) (transfer full): The pattern data.
* @color_bytes: (out) (array length=num_color_bytes) (element-type guint8) (transfer full): The pattern data.
* *
* Gets information about the pattern (including pixels). * Gets information about the pattern (including pixels).
* *
@ -113,8 +112,7 @@ gimp_pattern_get_pixels (GimpPattern *pattern,
gint *width, gint *width,
gint *height, gint *height,
gint *bpp, gint *bpp,
gint *num_color_bytes, GBytes **color_bytes)
guint8 **color_bytes)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -132,7 +130,6 @@ gimp_pattern_get_pixels (GimpPattern *pattern,
*width = 0; *width = 0;
*height = 0; *height = 0;
*bpp = 0; *bpp = 0;
*num_color_bytes = 0;
*color_bytes = NULL; *color_bytes = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
@ -142,8 +139,7 @@ gimp_pattern_get_pixels (GimpPattern *pattern,
*width = GIMP_VALUES_GET_INT (return_vals, 1); *width = GIMP_VALUES_GET_INT (return_vals, 1);
*height = GIMP_VALUES_GET_INT (return_vals, 2); *height = GIMP_VALUES_GET_INT (return_vals, 2);
*bpp = GIMP_VALUES_GET_INT (return_vals, 3); *bpp = GIMP_VALUES_GET_INT (return_vals, 3);
*num_color_bytes = GIMP_VALUES_GET_INT (return_vals, 4); *color_bytes = GIMP_VALUES_DUP_BYTES (return_vals, 4);
*color_bytes = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 5);
} }
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);

View File

@ -40,8 +40,7 @@ gboolean gimp_pattern_get_pixels (GimpPattern *pattern,
gint *width, gint *width,
gint *height, gint *height,
gint *bpp, gint *bpp,
gint *num_color_bytes, GBytes **color_bytes);
guint8 **color_bytes);
gboolean gimp_pattern_id_is_valid (const gchar *id); gboolean gimp_pattern_id_is_valid (const gchar *id);

View File

@ -388,7 +388,8 @@ static _PreviewImage
gimp_pattern_select_button_get_pattern_image (GimpPatternSelectButton *self) gimp_pattern_select_button_get_pattern_image (GimpPatternSelectButton *self)
{ {
GimpPattern *pattern; GimpPattern *pattern;
gint pixelels_size; gsize pixelels_size;
GBytes *color_bytes;
_PreviewImage result; _PreviewImage result;
g_debug ("%s", G_STRFUNC); g_debug ("%s", G_STRFUNC);
@ -399,8 +400,8 @@ gimp_pattern_select_button_get_pattern_image (GimpPatternSelectButton *self)
&result.width, &result.width,
&result.height, &result.height,
&result.bpp, &result.bpp,
&pixelels_size, /* discarded. */ &color_bytes);
&result.pixelels); result.pixelels = g_bytes_unref_to_data (color_bytes, &pixelels_size);
return result; return result;
} }

View File

@ -606,15 +606,14 @@ gboolean
gimp_pdb_get_data (const gchar *identifier, gimp_pdb_get_data (const gchar *identifier,
gpointer data) gpointer data)
{ {
gint size; GBytes *hack = NULL;
guint8 *hack;
gboolean success; gboolean success;
success = _gimp_pdb_get_data (identifier, &size, &hack); success = _gimp_pdb_get_data (identifier, &hack);
if (hack) if (hack)
{ {
memcpy (data, (gconstpointer) hack, size * sizeof (guint8)); memcpy (data, g_bytes_get_data (hack, NULL), g_bytes_get_size (hack));
g_free (hack); g_free (hack);
} }
@ -642,8 +641,8 @@ gimp_pdb_get_data_size (const gchar *identifier)
/** /**
* gimp_pdb_set_data: * gimp_pdb_set_data:
* @identifier: The identifier associated with data. * @identifier: The identifier associated with data.
* @data: A byte array containing data. * @data: (array length=data_len): A byte array containing data.
* @bytes: The number of bytes in the data * @data_len: The number of bytes in the data
* *
* Associates the specified identifier with the supplied data. * Associates the specified identifier with the supplied data.
* *
@ -656,9 +655,16 @@ gimp_pdb_get_data_size (const gchar *identifier)
gboolean gboolean
gimp_pdb_set_data (const gchar *identifier, gimp_pdb_set_data (const gchar *identifier,
gconstpointer data, gconstpointer data,
guint32 bytes) guint32 data_len)
{ {
return _gimp_pdb_set_data (identifier, bytes, data); GBytes *bytes;
gboolean ret;
bytes = g_bytes_new_static (data, data_len);
ret = _gimp_pdb_set_data (identifier, bytes);
g_bytes_unref (bytes);
return ret;
} }

View File

@ -117,7 +117,7 @@ gboolean gimp_pdb_get_data (const gchar *identifier,
gint gimp_pdb_get_data_size (const gchar *identifier); gint gimp_pdb_get_data_size (const gchar *identifier);
gboolean gimp_pdb_set_data (const gchar *identifier, gboolean gimp_pdb_set_data (const gchar *identifier,
gconstpointer data, gconstpointer data,
guint32 bytes); guint32 data_len);
G_END_DECLS G_END_DECLS

View File

@ -613,8 +613,7 @@ _gimp_pdb_get_proc_menu_paths (const gchar *procedure_name)
* _gimp_pdb_set_proc_icon: * _gimp_pdb_set_proc_icon:
* @procedure_name: The procedure for which to install the icon. * @procedure_name: The procedure for which to install the icon.
* @icon_type: The type of the icon. * @icon_type: The type of the icon.
* @icon_data_length: The length of 'icon-data'. * @icon_data: The procedure's icon. The format depends on the 'icon_type' parameter.
* @icon_data: (array length=icon_data_length) (element-type guint8): The procedure's icon. The format depends on the 'icon_type' parameter.
* *
* Register an icon for a plug-in procedure. * Register an icon for a plug-in procedure.
* *
@ -627,8 +626,7 @@ _gimp_pdb_get_proc_menu_paths (const gchar *procedure_name)
gboolean gboolean
_gimp_pdb_set_proc_icon (const gchar *procedure_name, _gimp_pdb_set_proc_icon (const gchar *procedure_name,
GimpIconType icon_type, GimpIconType icon_type,
gint icon_data_length, GBytes *icon_data)
const guint8 *icon_data)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -637,10 +635,8 @@ _gimp_pdb_set_proc_icon (const gchar *procedure_name,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, procedure_name, G_TYPE_STRING, procedure_name,
GIMP_TYPE_ICON_TYPE, icon_type, GIMP_TYPE_ICON_TYPE, icon_type,
G_TYPE_INT, icon_data_length, G_TYPE_BYTES, icon_data,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 3), icon_data, icon_data_length);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-pdb-set-proc-icon", "gimp-pdb-set-proc-icon",
@ -1179,8 +1175,7 @@ _gimp_pdb_set_batch_interpreter (const gchar *procedure_name,
/** /**
* _gimp_pdb_get_data: * _gimp_pdb_get_data:
* @identifier: The identifier associated with data. * @identifier: The identifier associated with data.
* @bytes: (out): The number of bytes in the data. * @data: (out) (transfer full): A byte array containing data.
* @data: (out) (array length=bytes) (element-type guint8) (transfer full): A byte array containing data.
* *
* Returns data associated with the specified identifier. * Returns data associated with the specified identifier.
* *
@ -1193,8 +1188,7 @@ _gimp_pdb_set_batch_interpreter (const gchar *procedure_name,
**/ **/
gboolean gboolean
_gimp_pdb_get_data (const gchar *identifier, _gimp_pdb_get_data (const gchar *identifier,
gint *bytes, GBytes **data)
guint8 **data)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -1209,16 +1203,12 @@ _gimp_pdb_get_data (const gchar *identifier,
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
*bytes = 0;
*data = NULL; *data = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
if (success) if (success)
{ *data = GIMP_VALUES_DUP_BYTES (return_vals, 1);
*bytes = GIMP_VALUES_GET_INT (return_vals, 1);
*data = GIMP_VALUES_DUP_UINT8_ARRAY (return_vals, 2);
}
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
@ -1264,8 +1254,7 @@ _gimp_pdb_get_data_size (const gchar *identifier)
/** /**
* _gimp_pdb_set_data: * _gimp_pdb_set_data:
* @identifier: The identifier associated with data. * @identifier: The identifier associated with data.
* @bytes: The number of bytes in the data. * @data: A byte array containing data.
* @data: (array length=bytes) (element-type guint8): A byte array containing data.
* *
* Associates the specified identifier with the supplied data. * Associates the specified identifier with the supplied data.
* *
@ -1276,9 +1265,8 @@ _gimp_pdb_get_data_size (const gchar *identifier)
* Returns: TRUE on success. * Returns: TRUE on success.
**/ **/
gboolean gboolean
_gimp_pdb_set_data (const gchar *identifier, _gimp_pdb_set_data (const gchar *identifier,
gint bytes, GBytes *data)
const guint8 *data)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
@ -1286,10 +1274,8 @@ _gimp_pdb_set_data (const gchar *identifier,
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, identifier, G_TYPE_STRING, identifier,
G_TYPE_INT, bytes, G_TYPE_BYTES, data,
GIMP_TYPE_UINT8_ARRAY, NULL,
G_TYPE_NONE); G_TYPE_NONE);
gimp_value_set_uint8_array (gimp_value_array_index (args, 2), data, bytes);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (), return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-pdb-set-data", "gimp-pdb-set-data",

View File

@ -64,8 +64,7 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_add_proc_menu_path (const gcha
G_GNUC_INTERNAL gchar** _gimp_pdb_get_proc_menu_paths (const gchar *procedure_name); G_GNUC_INTERNAL gchar** _gimp_pdb_get_proc_menu_paths (const gchar *procedure_name);
G_GNUC_INTERNAL gboolean _gimp_pdb_set_proc_icon (const gchar *procedure_name, G_GNUC_INTERNAL gboolean _gimp_pdb_set_proc_icon (const gchar *procedure_name,
GimpIconType icon_type, GimpIconType icon_type,
gint icon_data_length, GBytes *icon_data);
const guint8 *icon_data);
G_GNUC_INTERNAL gboolean _gimp_pdb_set_proc_documentation (const gchar *procedure_name, G_GNUC_INTERNAL gboolean _gimp_pdb_set_proc_documentation (const gchar *procedure_name,
const gchar *blurb, const gchar *blurb,
const gchar *help, const gchar *help,
@ -100,12 +99,10 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_set_file_proc_thumbnail_loader (const gcha
G_GNUC_INTERNAL gboolean _gimp_pdb_set_batch_interpreter (const gchar *procedure_name, G_GNUC_INTERNAL gboolean _gimp_pdb_set_batch_interpreter (const gchar *procedure_name,
const gchar *interpreter_name); const gchar *interpreter_name);
G_GNUC_INTERNAL gboolean _gimp_pdb_get_data (const gchar *identifier, G_GNUC_INTERNAL gboolean _gimp_pdb_get_data (const gchar *identifier,
gint *bytes, GBytes **data);
guint8 **data);
G_GNUC_INTERNAL gint _gimp_pdb_get_data_size (const gchar *identifier); G_GNUC_INTERNAL gint _gimp_pdb_get_data_size (const gchar *identifier);
G_GNUC_INTERNAL gboolean _gimp_pdb_set_data (const gchar *identifier, G_GNUC_INTERNAL gboolean _gimp_pdb_set_data (const gchar *identifier,
gint bytes, GBytes *data);
const guint8 *data);
G_END_DECLS G_END_DECLS

View File

@ -344,34 +344,34 @@ G_BEGIN_DECLS
g_value_take_param (gimp_value_array_index (args, n), value) g_value_take_param (gimp_value_array_index (args, n), value)
/* uint8 array */ /* bytes */
#define GIMP_PROC_ARG_UINT8_ARRAY(procedure, name, nick, blurb, flags) \ #define GIMP_PROC_ARG_BYTES(procedure, name, nick, blurb, flags) \
gimp_procedure_add_argument (procedure,\ gimp_procedure_add_argument (procedure,\
gimp_param_spec_uint8_array (name, nick, blurb,\ g_param_spec_boxed (name, nick, blurb,\
flags)) G_TYPE_BYTES, flags))
#define GIMP_PROC_AUX_ARG_UINT8_ARRAY(procedure, name, nick, blurb, flags) \ #define GIMP_PROC_AUX_ARG_BYTES(procedure, name, nick, blurb, flags) \
gimp_procedure_add_aux_argument (procedure,\ gimp_procedure_add_aux_argument (procedure,\
gimp_param_spec_uint8_array (name, nick, blurb,\ g_param_spec_boxed (name, nick, blurb,\
flags)) G_TYPE_BYTES, flags))
#define GIMP_PROC_VAL_UINT8_ARRAY(procedure, name, nick, blurb, flags) \ #define GIMP_PROC_VAL_BYTES(procedure, name, nick, blurb, flags) \
gimp_procedure_add_return_value (procedure,\ gimp_procedure_add_return_value (procedure,\
gimp_param_spec_uint8_array (name, nick, blurb,\ g_param_spec_boxed (name, nick, blurb,\
flags)) G_TYPE_BYTES, flags))
#define GIMP_VALUES_GET_UINT8_ARRAY(args, n) \ #define GIMP_VALUES_GET_BYTES(args, n) \
gimp_value_get_uint8_array (gimp_value_array_index (args, n)) g_value_get_boxed (gimp_value_array_index (args, n))
#define GIMP_VALUES_DUP_UINT8_ARRAY(args, n) \ #define GIMP_VALUES_DUP_BYTES(args, n) \
gimp_value_dup_uint8_array (gimp_value_array_index (args, n)) g_value_dup_boxed (gimp_value_array_index (args, n))
#define GIMP_VALUES_SET_UINT8_ARRAY(args, n, value, length) \ #define GIMP_VALUES_SET_BYTES(args, n, value, length) \
gimp_value_set_uint8_array (gimp_value_array_index (args, n), value, length) g_value_set_boxed (gimp_value_array_index (args, n), value)
#define GIMP_VALUES_TAKE_UINT8_ARRAY(args, n, value, length) \ #define GIMP_VALUES_TAKE_BYTES(args, n, value, length) \
gimp_value_take_uint8_array (gimp_value_array_index (args, n), value, length) g_value_take_boxed (gimp_value_array_index (args, n), value)
/* int32 array */ /* int32 array */

View File

@ -314,6 +314,7 @@ gimp_procedure_install_icon (GimpProcedure *procedure)
GimpIconType icon_type; GimpIconType icon_type;
guint8 *icon_data = NULL; guint8 *icon_data = NULL;
gsize icon_data_length = 0; gsize icon_data_length = 0;
GBytes *icon_bytes = NULL;
icon_type = gimp_procedure_get_icon_type (procedure); icon_type = gimp_procedure_get_icon_type (procedure);
@ -323,7 +324,8 @@ gimp_procedure_install_icon (GimpProcedure *procedure)
{ {
icon_data = (guint8 *) gimp_procedure_get_icon_name (procedure); icon_data = (guint8 *) gimp_procedure_get_icon_name (procedure);
if (icon_data) if (icon_data)
icon_data_length = strlen ((gchar *) icon_data) + 1; icon_bytes = g_bytes_new_static (icon_data,
strlen ((gchar *) icon_data) + 1);
} }
break; break;
@ -332,9 +334,12 @@ gimp_procedure_install_icon (GimpProcedure *procedure)
GdkPixbuf *pixbuf = gimp_procedure_get_icon_pixbuf (procedure); GdkPixbuf *pixbuf = gimp_procedure_get_icon_pixbuf (procedure);
if (pixbuf) if (pixbuf)
gdk_pixbuf_save_to_buffer (pixbuf, {
(gchar **) &icon_data, &icon_data_length, gdk_pixbuf_save_to_buffer (pixbuf,
"png", NULL, NULL); (gchar **) &icon_data, &icon_data_length,
"png", NULL, NULL);
icon_bytes = g_bytes_new_take (icon_data, icon_data_length);
}
} }
break; break;
@ -346,6 +351,7 @@ gimp_procedure_install_icon (GimpProcedure *procedure)
{ {
icon_data = (guchar *) g_file_get_uri (file); icon_data = (guchar *) g_file_get_uri (file);
icon_data_length = strlen ((gchar *) icon_data) + 1; icon_data_length = strlen ((gchar *) icon_data) + 1;
icon_bytes = g_bytes_new_take (icon_data, icon_data_length);
} }
} }
break; break;
@ -353,18 +359,7 @@ gimp_procedure_install_icon (GimpProcedure *procedure)
if (icon_data) if (icon_data)
_gimp_pdb_set_proc_icon (gimp_procedure_get_name (procedure), _gimp_pdb_set_proc_icon (gimp_procedure_get_name (procedure),
icon_type, icon_data_length, icon_data); icon_type, icon_bytes);
switch (icon_type)
{
case GIMP_ICON_TYPE_ICON_NAME:
break;
case GIMP_ICON_TYPE_PIXBUF:
case GIMP_ICON_TYPE_IMAGE_FILE:
g_free (icon_data);
break;
}
} }
static void static void

View File

@ -193,16 +193,10 @@ create_callback_PDB_procedure_params (GimpProcedure *procedure,
0, 10000, 0, 0, 10000, 0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "mask-len", GIMP_PROC_ARG_BYTES (procedure, "mask-data",
"Mask length", "Mask data",
"Length of brush mask data", "The brush mask data",
0, G_MAXINT, 0, G_PARAM_READWRITE);
G_PARAM_READWRITE);
GIMP_PROC_ARG_UINT8_ARRAY (procedure, "mask-data",
"Mask data",
"The brush mask data",
G_PARAM_READWRITE);
} }
else if (g_type_is_a (resource_type, GIMP_TYPE_PALETTE)) else if (g_type_is_a (resource_type, GIMP_TYPE_PALETTE))
{ {
@ -232,16 +226,10 @@ create_callback_PDB_procedure_params (GimpProcedure *procedure,
0, 10000, 0, 0, 10000, 0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "mask-len", GIMP_PROC_ARG_BYTES (procedure, "mask-data",
"Mask length", "Mask data",
"Length of pattern mask data", "The pattern mask data",
0, G_MAXINT, 0, G_PARAM_READWRITE);
G_PARAM_READWRITE);
GIMP_PROC_ARG_UINT8_ARRAY (procedure, "mask-data",
"Mask data",
"The pattern mask data",
G_PARAM_READWRITE);
} }
else else
{ {

View File

@ -519,8 +519,8 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
} }
else else
{ {
guchar *sel; GBytes *sel;
guchar *src; GBytes *src;
GimpSelection *selection; GimpSelection *selection;
gint w, h; gint w, h;
gint bpp; gint bpp;
@ -533,9 +533,6 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
selection = gimp_image_get_selection (image); selection = gimp_image_get_selection (image);
w = width;
h = height;
gimp_zoom_preview_get_source_area (preview, gimp_zoom_preview_get_source_area (preview,
&src_x, &src_y, &src_x, &src_y,
&src_width, &src_height); &src_width, &src_height);
@ -543,22 +540,24 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
src = gimp_drawable_get_sub_thumbnail_data (priv->drawable, src = gimp_drawable_get_sub_thumbnail_data (priv->drawable,
src_x, src_y, src_x, src_y,
src_width, src_height, src_width, src_height,
width, height,
&w, &h, &bpp); &w, &h, &bpp);
gimp_drawable_get_offsets (priv->drawable, &offsx, &offsy); gimp_drawable_get_offsets (priv->drawable, &offsx, &offsy);
sel = gimp_drawable_get_sub_thumbnail_data (GIMP_DRAWABLE (selection), sel = gimp_drawable_get_sub_thumbnail_data (GIMP_DRAWABLE (selection),
src_x + offsx, src_y + offsy, src_x + offsx, src_y + offsy,
src_width, src_height, src_width, src_height,
&width, &height, &bpp); width, height,
&w, &h, &bpp);
gimp_preview_area_mask (GIMP_PREVIEW_AREA (area), gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
0, 0, width, height, 0, 0, width, height,
gimp_drawable_type (priv->drawable), gimp_drawable_type (priv->drawable),
src, width * gimp_drawable_get_bpp (priv->drawable), g_bytes_get_data (src, NULL), width * gimp_drawable_get_bpp (priv->drawable),
buffer, rowstride, buffer, rowstride,
sel, width); g_bytes_get_data (sel, NULL), width);
g_free (sel); g_bytes_unref (sel);
g_free (src); g_bytes_unref (src);
} }
} }
@ -911,6 +910,8 @@ gimp_zoom_preview_get_source (GimpZoomPreview *preview,
gint src_y; gint src_y;
gint src_width; gint src_width;
gint src_height; gint src_height;
GBytes *src_bytes;
gsize src_bytes_size;
gimp_preview_get_size (gimp_preview, width, height); gimp_preview_get_size (gimp_preview, width, height);
@ -918,10 +919,12 @@ gimp_zoom_preview_get_source (GimpZoomPreview *preview,
&src_x, &src_y, &src_x, &src_y,
&src_width, &src_height); &src_width, &src_height);
return gimp_drawable_get_sub_thumbnail_data (drawable, src_bytes = gimp_drawable_get_sub_thumbnail_data (drawable,
src_x, src_y, src_x, src_y,
src_width, src_height, src_width, src_height,
width, height, bpp); *width, *height,
width, height, bpp);
return g_bytes_unref_to_data (src_bytes, &src_bytes_size);
} }
else else
{ {

View File

@ -120,10 +120,8 @@ EXPORTS
gimp_param_spec_object_array gimp_param_spec_object_array
gimp_param_spec_parasite gimp_param_spec_parasite
gimp_param_spec_rgb_array gimp_param_spec_rgb_array
gimp_param_spec_uint8_array
gimp_param_spec_unit gimp_param_spec_unit
gimp_param_spec_value_array gimp_param_spec_value_array
gimp_param_uint8_array_get_type
gimp_param_unit_get_type gimp_param_unit_get_type
gimp_param_value_array_get_type gimp_param_value_array_get_type
gimp_parasite_compare gimp_parasite_compare
@ -184,7 +182,6 @@ EXPORTS
gimp_type_get_translation_domain gimp_type_get_translation_domain
gimp_type_set_translation_context gimp_type_set_translation_context
gimp_type_set_translation_domain gimp_type_set_translation_domain
gimp_uint8_array_get_type
gimp_unit_format_string gimp_unit_format_string
gimp_unit_get_abbreviation gimp_unit_get_abbreviation
gimp_unit_get_deletion_flag gimp_unit_get_deletion_flag
@ -223,12 +220,10 @@ EXPORTS
gimp_value_dup_int32_array gimp_value_dup_int32_array
gimp_value_dup_object_array gimp_value_dup_object_array
gimp_value_dup_rgb_array gimp_value_dup_rgb_array
gimp_value_dup_uint8_array
gimp_value_get_float_array gimp_value_get_float_array
gimp_value_get_int32_array gimp_value_get_int32_array
gimp_value_get_object_array gimp_value_get_object_array
gimp_value_get_rgb_array gimp_value_get_rgb_array
gimp_value_get_uint8_array
gimp_value_set_float_array gimp_value_set_float_array
gimp_value_set_int32_array gimp_value_set_int32_array
gimp_value_set_object_array gimp_value_set_object_array
@ -237,13 +232,10 @@ EXPORTS
gimp_value_set_static_int32_array gimp_value_set_static_int32_array
gimp_value_set_static_object_array gimp_value_set_static_object_array
gimp_value_set_static_rgb_array gimp_value_set_static_rgb_array
gimp_value_set_static_uint8_array
gimp_value_set_uint8_array
gimp_value_take_float_array gimp_value_take_float_array
gimp_value_take_int32_array gimp_value_take_int32_array
gimp_value_take_object_array gimp_value_take_object_array
gimp_value_take_rgb_array gimp_value_take_rgb_array
gimp_value_take_uint8_array
gimp_vectors_stroke_type_get_type gimp_vectors_stroke_type_get_type
gimp_wire_clear_error gimp_wire_clear_error
gimp_wire_destroy gimp_wire_destroy

View File

@ -254,173 +254,6 @@ gimp_value_take_array (GValue *value,
} }
/*
* GIMP_TYPE_UINT8_ARRAY
*/
typedef GimpArray GimpUint8Array;
G_DEFINE_BOXED_TYPE (GimpUint8Array, gimp_uint8_array, gimp_array_copy, gimp_array_free)
/*
* GIMP_TYPE_PARAM_UINT8_ARRAY
*/
static void gimp_param_uint8_array_class_init (GParamSpecClass *klass);
static void gimp_param_uint8_array_init (GParamSpec *pspec);
GType
gimp_param_uint8_array_get_type (void)
{
static GType type = 0;
if (! type)
{
const GTypeInfo info =
{
sizeof (GParamSpecClass),
NULL, NULL,
(GClassInitFunc) gimp_param_uint8_array_class_init,
NULL, NULL,
sizeof (GimpParamSpecUInt8Array),
0,
(GInstanceInitFunc) gimp_param_uint8_array_init
};
type = g_type_register_static (GIMP_TYPE_PARAM_ARRAY,
"GimpParamUInt8Array", &info, 0);
}
return type;
}
static void
gimp_param_uint8_array_class_init (GParamSpecClass *klass)
{
klass->value_type = GIMP_TYPE_UINT8_ARRAY;
}
static void
gimp_param_uint8_array_init (GParamSpec *pspec)
{
}
/**
* gimp_param_spec_uint8_array:
* @name: Canonical name of the property specified.
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecUInt8Array specifying a
* #GIMP_TYPE_UINT8_ARRAY property.
*
* See g_param_spec_internal() for details on property names.
*
* Returns: (transfer full): The newly created #GimpParamSpecUInt8Array.
*
* Since: 3.0
**/
GParamSpec *
gimp_param_spec_uint8_array (const gchar *name,
const gchar *nick,
const gchar *blurb,
GParamFlags flags)
{
GimpParamSpecArray *array_spec;
array_spec = g_param_spec_internal (GIMP_TYPE_PARAM_UINT8_ARRAY,
name, nick, blurb, flags);
return G_PARAM_SPEC (array_spec);
}
/**
* gimp_value_get_uint8_array:
* @value: A valid value of type %GIMP_TYPE_UINT8_ARRAY
*
* Gets the contents of a %GIMP_TYPE_UINT8_ARRAY #GValue
*
* Returns: (transfer none) (array): The contents of @value
*/
const guint8 *
gimp_value_get_uint8_array (const GValue *value)
{
g_return_val_if_fail (GIMP_VALUE_HOLDS_UINT8_ARRAY (value), NULL);
return gimp_value_get_array (value);
}
/**
* gimp_value_dup_uint8_array:
* @value: A valid value of type %GIMP_TYPE_UINT8_ARRAY
*
* Gets the contents of a %GIMP_TYPE_UINT8_ARRAY #GValue
*
* Returns: (transfer full) (array): The contents of @value
*/
guint8 *
gimp_value_dup_uint8_array (const GValue *value)
{
g_return_val_if_fail (GIMP_VALUE_HOLDS_UINT8_ARRAY (value), NULL);
return gimp_value_dup_array (value);
}
/**
* gimp_value_set_uint8_array:
* @value: A valid value of type %GIMP_TYPE_UINT8_ARRAY
* @data: (array length=length): A #guint8 array
* @length: The number of elements in @data
*
* Sets the contents of @value to @data.
*/
void
gimp_value_set_uint8_array (GValue *value,
const guint8 *data,
gsize length)
{
g_return_if_fail (GIMP_VALUE_HOLDS_UINT8_ARRAY (value));
gimp_value_set_array (value, data, length);
}
/**
* gimp_value_set_static_uint8_array:
* @value: A valid value of type %GIMP_TYPE_UINT8_ARRAY
* @data: (array length=length): A #guint8 array
* @length: The number of elements in @data
*
* Sets the contents of @value to @data, without copying the data.
*/
void
gimp_value_set_static_uint8_array (GValue *value,
const guint8 *data,
gsize length)
{
g_return_if_fail (GIMP_VALUE_HOLDS_UINT8_ARRAY (value));
gimp_value_set_static_array (value, data, length);
}
/**
* gimp_value_take_uint8_array:
* @value: A valid value of type %GIMP_TYPE_UINT8_ARRAY
* @data: (transfer full) (array length=length): A #guint8 array
* @length: The number of elements in @data
*
* Sets the contents of @value to @data, and takes ownership of @data.
*/
void
gimp_value_take_uint8_array (GValue *value,
guint8 *data,
gsize length)
{
g_return_if_fail (GIMP_VALUE_HOLDS_UINT8_ARRAY (value));
gimp_value_take_array (value, data, length);
}
/* /*
* GIMP_TYPE_INT32_ARRAY * GIMP_TYPE_INT32_ARRAY
*/ */

View File

@ -128,51 +128,6 @@ GParamSpec * gimp_param_spec_array (const gchar *name,
GParamFlags flags); GParamFlags flags);
/*
* GIMP_TYPE_UINT8_ARRAY
*/
#define GIMP_TYPE_UINT8_ARRAY (gimp_uint8_array_get_type ())
#define GIMP_VALUE_HOLDS_UINT8_ARRAY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_UINT8_ARRAY))
GType gimp_uint8_array_get_type (void) G_GNUC_CONST;
/*
* GIMP_TYPE_PARAM_UINT8_ARRAY
*/
#define GIMP_TYPE_PARAM_UINT8_ARRAY (gimp_param_uint8_array_get_type ())
#define GIMP_PARAM_SPEC_UINT8_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_UINT8_ARRAY, GimpParamSpecUInt8Array))
#define GIMP_IS_PARAM_SPEC_UINT8_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_UINT8_ARRAY))
typedef struct _GimpParamSpecUInt8Array GimpParamSpecUInt8Array;
struct _GimpParamSpecUInt8Array
{
GimpParamSpecArray parent_instance;
};
GType gimp_param_uint8_array_get_type (void) G_GNUC_CONST;
GParamSpec * gimp_param_spec_uint8_array (const gchar *name,
const gchar *nick,
const gchar *blurb,
GParamFlags flags);
const guint8 * gimp_value_get_uint8_array (const GValue *value);
guint8 * gimp_value_dup_uint8_array (const GValue *value);
void gimp_value_set_uint8_array (GValue *value,
const guint8 *data,
gsize length);
void gimp_value_set_static_uint8_array (GValue *value,
const guint8 *data,
gsize length);
void gimp_value_take_uint8_array (GValue *value,
guint8 *data,
gsize length);
/* /*
* GIMP_TYPE_INT32_ARRAY * GIMP_TYPE_INT32_ARRAY
*/ */

View File

@ -75,7 +75,7 @@ GParamSpec * gimp_param_spec_parasite (const gchar *name,
* @name: the parasite name, USE A UNIQUE PREFIX * @name: the parasite name, USE A UNIQUE PREFIX
* @flags: the parasite flags, like save in XCF etc. * @flags: the parasite flags, like save in XCF etc.
* @size: the parasite size in bytes * @size: the parasite size in bytes
* @data: the parasite data, the owner os the parasite is responsible * @data: (array length=size): the parasite data, the owner os the parasite is responsible
* for tracking byte order and internal structure * for tracking byte order and internal structure
**/ **/
struct _GimpParasite struct _GimpParasite

View File

@ -1638,6 +1638,26 @@ _gp_params_read (GIOChannel *channel,
} }
break; break;
case GP_PARAM_TYPE_BYTES:
{
guint32 data_len;
guint8* data;
if (! _gimp_wire_read_int32 (channel, &data_len, 1, user_data))
goto cleanup;
data = g_new0 (guint8, data_len);
if (! _gimp_wire_read_int8 (channel, data, data_len, user_data))
{
g_free (data);
goto cleanup;
}
(*params)[i].data.d_bytes = g_bytes_new_take (data, data_len);
}
break;
case GP_PARAM_TYPE_STRV: case GP_PARAM_TYPE_STRV:
{ {
guint32 size; guint32 size;
@ -1803,6 +1823,22 @@ _gp_params_write (GIOChannel *channel,
return; return;
break; break;
case GP_PARAM_TYPE_BYTES:
{
const guint8 *bytes = NULL;
guint32 size = 0;
if (params[i].data.d_bytes)
{
bytes = g_bytes_get_data (params[i].data.d_bytes, (gsize *) &size);
}
if (! _gimp_wire_write_int32 (channel, &size, 1, user_data) ||
! _gimp_wire_write_int8 (channel, bytes, size, user_data))
return;
}
break;
case GP_PARAM_TYPE_STRV: case GP_PARAM_TYPE_STRV:
{ {
gint size; gint size;
@ -1901,6 +1937,10 @@ _gp_params_destroy (GPParam *params,
g_free (params[i].data.d_array.data); g_free (params[i].data.d_array.data);
break; break;
case GP_PARAM_TYPE_BYTES:
g_bytes_unref (params[i].data.d_bytes);
break;
case GP_PARAM_TYPE_STRV: case GP_PARAM_TYPE_STRV:
g_strfreev (params[i].data.d_strv); g_strfreev (params[i].data.d_strv);
break; break;

View File

@ -66,6 +66,7 @@ typedef enum
GP_PARAM_TYPE_FLOAT, GP_PARAM_TYPE_FLOAT,
GP_PARAM_TYPE_STRING, GP_PARAM_TYPE_STRING,
GP_PARAM_TYPE_STRV, GP_PARAM_TYPE_STRV,
GP_PARAM_TYPE_BYTES,
GP_PARAM_TYPE_FILE, GP_PARAM_TYPE_FILE,
GP_PARAM_TYPE_COLOR, GP_PARAM_TYPE_COLOR,
GP_PARAM_TYPE_PARASITE, GP_PARAM_TYPE_PARASITE,
@ -250,6 +251,7 @@ struct _GPParam
gdouble d_float; gdouble d_float;
gchar *d_string; gchar *d_string;
gchar **d_strv; gchar **d_strv;
GBytes *d_bytes;
GimpRGB d_color; GimpRGB d_color;
GimpParasite d_parasite; GimpParasite d_parasite;
GPParamArray d_array; GPParamArray d_array;

View File

@ -308,12 +308,7 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
} }
else if (GIMP_IS_PARAM_SPEC_ARRAY (pspec)) else if (GIMP_IS_PARAM_SPEC_ARRAY (pspec))
{ {
if (GIMP_IS_PARAM_SPEC_UINT8_ARRAY (pspec)) if (GIMP_IS_PARAM_SPEC_INT32_ARRAY (pspec))
{
copy = gimp_param_spec_uint8_array (name, nick, blurb,
flags);
}
else if (GIMP_IS_PARAM_SPEC_INT32_ARRAY (pspec))
{ {
copy = gimp_param_spec_int32_array (name, nick, blurb, copy = gimp_param_spec_int32_array (name, nick, blurb,
flags); flags);
@ -367,11 +362,10 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
{ {
GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec); GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
if (value_type == G_TYPE_STRV) if (value_type == G_TYPE_BYTES ||
value_type == G_TYPE_STRV)
{ {
copy = g_param_spec_boxed (name, nick, blurb, copy = g_param_spec_boxed (name, nick, blurb, value_type, flags);
value_type,
flags);
} }
} }

View File

@ -604,14 +604,6 @@ gimp_param_spec_int32_array ("$name",
"$nick", "$nick",
"$blurb", "$blurb",
$flags) $flags)
CODE
}
elsif ($pdbtype eq 'int8array') {
$pspec = <<CODE;
gimp_param_spec_uint8_array ("$name",
"$nick",
"$blurb",
$flags)
CODE CODE
} }
elsif ($pdbtype eq 'floatarray') { elsif ($pdbtype eq 'floatarray') {
@ -620,6 +612,15 @@ gimp_param_spec_float_array ("$name",
"$nick", "$nick",
"$blurb", "$blurb",
$flags) $flags)
CODE
}
elsif ($pdbtype eq 'bytes') {
$pspec = <<CODE;
g_param_spec_boxed ("$name",
"$nick",
"$blurb",
G_TYPE_BYTES,
$flags)
CODE CODE
} }
elsif ($pdbtype eq 'strv') { elsif ($pdbtype eq 'strv') {

View File

@ -309,14 +309,12 @@ HELP
desc => 'The brush height' }, desc => 'The brush height' },
{ name => 'mask_bpp', type => 'int32', { name => 'mask_bpp', type => 'int32',
desc => 'The brush mask bpp' }, desc => 'The brush mask bpp' },
{ name => 'mask_bytes', type => 'int8array', { name => 'mask_bytes', type => 'bytes',
desc => 'The brush mask data', desc => 'The brush mask data' },
array => { desc => 'Length of brush mask data' } },
{ name => 'color_bpp', type => 'int32', { name => 'color_bpp', type => 'int32',
desc => 'The brush color bpp' }, desc => 'The brush color bpp' },
{ name => 'color_bytes', type => 'int8array', { name => 'color_bytes', type => 'bytes',
desc => 'The brush color data', desc => 'The brush color data' }
array => { desc => 'Length of brush color data' } }
); );
%invoke = ( %invoke = (
@ -326,6 +324,8 @@ HELP
GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush); GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush);
const Babl *format; const Babl *format;
gpointer data; gpointer data;
gsize num_mask_bytes;
gsize num_color_bytes;
format = gimp_babl_compat_u8_mask_format ( format = gimp_babl_compat_u8_mask_format (
gimp_temp_buf_get_format (mask)); gimp_temp_buf_get_format (mask));
@ -336,7 +336,7 @@ HELP
mask_bpp = babl_format_get_bytes_per_pixel (format); mask_bpp = babl_format_get_bytes_per_pixel (format);
num_mask_bytes = gimp_temp_buf_get_height (mask) * num_mask_bytes = gimp_temp_buf_get_height (mask) *
gimp_temp_buf_get_width (mask) * mask_bpp; gimp_temp_buf_get_width (mask) * mask_bpp;
mask_bytes = g_memdup2 (data, num_mask_bytes); mask_bytes = g_bytes_new (data, num_mask_bytes);
gimp_temp_buf_unlock (mask, data); gimp_temp_buf_unlock (mask, data);
@ -350,7 +350,7 @@ HELP
num_color_bytes = gimp_temp_buf_get_height (pixmap) * num_color_bytes = gimp_temp_buf_get_height (pixmap) *
gimp_temp_buf_get_width (pixmap) * gimp_temp_buf_get_width (pixmap) *
color_bpp; color_bpp;
color_bytes = g_memdup2 (data, num_color_bytes); color_bytes = g_bytes_new (data, num_color_bytes);
gimp_temp_buf_unlock (pixmap, data); gimp_temp_buf_unlock (pixmap, data);
} }

View File

@ -630,105 +630,6 @@ CODE
); );
} }
sub drawable_get_pixel {
$blurb = 'Gets the value of the pixel at the specified coordinates.';
$help = <<'HELP';
This procedure gets the pixel value at the specified coordinates. The
'num_channels' argument must always be equal to the bytes-per-pixel value for
the specified drawable.
HELP
&std_pdb_misc;
$date = '1997';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'x_coord', type => '0 <= int32',
desc => 'The x coordinate' },
{ name => 'y_coord', type => '0 <= int32',
desc => 'The y coordinate' }
);
@outargs = (
{ name => 'pixel', type => 'int8array',
desc => 'The pixel value',
array => { name => 'num_channels', no_validate => 1,
desc => 'The number of channels for the pixel' } }
);
%invoke = (
code => <<'CODE'
{
const Babl *format = gimp_drawable_get_format (drawable);
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
num_channels = babl_format_get_bytes_per_pixel (format);
pixel = g_new0 (guint8, num_channels);
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
x_coord, y_coord, NULL, pixel, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_set_pixel {
$blurb = 'Sets the value of the pixel at the specified coordinates.';
$help = <<'HELP';
This procedure sets the pixel value at the specified coordinates. The
'num_channels' argument must always be equal to the bytes-per-pixel value for
the specified drawable. Note that this function is not undoable, you should
use it only on drawables you just created yourself.
HELP
&std_pdb_misc;
$date = '1997';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'x_coord', type => '0 <= int32',
desc => 'The x coordinate' },
{ name => 'y_coord', type => '0 <= int32',
desc => 'The y coordinate' },
{ name => 'pixel', type => 'int8array',
desc => 'The pixel value',
array => { name => 'num_channels', no_validate => 1,
desc => 'The number of channels for the pixel' } }
);
%invoke = (
code => <<'CODE'
{
const Babl *format = gimp_drawable_get_format (drawable);
if (gimp_pdb_item_is_modifiable (GIMP_ITEM (drawable),
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
num_channels == babl_format_get_bytes_per_pixel (format))
{
gegl_buffer_set (gimp_drawable_get_buffer (drawable),
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
0, format, pixel, GEGL_AUTO_ROWSTRIDE);
}
else
success = FALSE;
}
CODE
);
}
sub drawable_thumbnail { sub drawable_thumbnail {
$blurb = 'Get a thumbnail of a drawable.'; $blurb = 'Get a thumbnail of a drawable.';
@ -759,10 +660,8 @@ HELP
desc => 'The previews height' }, desc => 'The previews height' },
{ name => 'bpp', type => 'int32', { name => 'bpp', type => 'int32',
desc => 'The previews bpp' }, desc => 'The previews bpp' },
{ name => 'thumbnail_data', type => 'int8array', { name => 'thumbnail_data', type => 'bytes',
desc => 'The thumbnail data', desc => 'The thumbnail data', }
array => { name => 'thumbnail_data_count',
desc => 'The number of bytes in thumbnail data' } }
); );
%invoke = ( %invoke = (
@ -796,9 +695,8 @@ HELP
actual_width = gimp_temp_buf_get_width (buf); actual_width = gimp_temp_buf_get_width (buf);
actual_height = gimp_temp_buf_get_height (buf); actual_height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf)); bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf); thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
thumbnail_data = g_memdup2 (gimp_temp_buf_get_data (buf), gimp_temp_buf_get_data_size (buf));
thumbnail_data_count);
gimp_temp_buf_unref (buf); gimp_temp_buf_unref (buf);
} }
@ -847,10 +745,8 @@ HELP
desc => 'The previews height' }, desc => 'The previews height' },
{ name => 'bpp', type => 'int32', { name => 'bpp', type => 'int32',
desc => 'The previews bpp' }, desc => 'The previews bpp' },
{ name => 'thumbnail_data', type => 'int8array', { name => 'thumbnail_data', type => 'bytes',
desc => 'The thumbnail data', desc => 'The thumbnail data' }
array => { name => 'thumbnail_data_count',
desc => 'The number of bytes in thumbnail data' } }
); );
%invoke = ( %invoke = (
@ -878,9 +774,8 @@ HELP
width = gimp_temp_buf_get_width (buf); width = gimp_temp_buf_get_width (buf);
height = gimp_temp_buf_get_height (buf); height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf)); bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf); thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
thumbnail_data = g_memdup2 (gimp_temp_buf_get_data (buf), gimp_temp_buf_get_data_size (buf));
thumbnail_data_count);
gimp_temp_buf_unref (buf); gimp_temp_buf_unref (buf);
} }
@ -1028,7 +923,6 @@ CODE
drawable_merge_shadow drawable_merge_shadow
drawable_free_shadow drawable_free_shadow
drawable_update drawable_update
drawable_get_pixel drawable_set_pixel
drawable_fill drawable_fill
drawable_offset drawable_offset
drawable_thumbnail drawable_thumbnail

View File

@ -325,10 +325,8 @@ HELP
desc => 'The width of the thumbnail' }, desc => 'The width of the thumbnail' },
{ name => 'height', type => 'int32', { name => 'height', type => 'int32',
desc => 'The height of the thumbnail' }, desc => 'The height of the thumbnail' },
{ name => 'thumb_data', type => 'int8array', { name => 'thumb_data', type => 'bytes',
desc => 'The thumbnail data', desc => 'The thumbnail data' }
array => { name => 'thumb_data_count',
desc => 'The number of bytes in thumbnail data' } }
); );
%invoke = ( %invoke = (
@ -340,9 +338,8 @@ HELP
{ {
width = gdk_pixbuf_get_width (pixbuf); width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf); height = gdk_pixbuf_get_height (pixbuf);
thumb_data_count = 3 * width * height; thumb_data = g_bytes_new (gdk_pixbuf_get_pixels (pixbuf),
thumb_data = g_memdup2 (gdk_pixbuf_get_pixels (pixbuf), 3 * width * height);
thumb_data_count);
g_object_unref (pixbuf); g_object_unref (pixbuf);
} }

View File

@ -1511,18 +1511,19 @@ HELP
); );
@outargs = ( @outargs = (
{ name => 'colormap', type => 'int8array', { name => 'colormap', type => 'bytes',
desc => "The image's colormap.", desc => "The image's colormap." }
array => { name => 'num_bytes',
desc => 'Number of bytes in the colormap array' } }
); );
%invoke = ( %invoke = (
headers => [ qw("core/gimpimage-colormap.h") ], headers => [ qw("core/gimpimage-colormap.h") ],
code => <<'CODE' code => <<'CODE'
{ {
num_bytes = 3 * gimp_image_get_colormap_size (image); guchar *colormap_data;
colormap = gimp_image_get_colormap (image);
colormap_data = gimp_image_get_colormap (image);
colormap = g_bytes_new_take (colormap_data,
gimp_image_get_colormap_size (image));
} }
CODE CODE
); );
@ -1545,17 +1546,18 @@ HELP
@inargs = ( @inargs = (
{ name => 'image', type => 'image', { name => 'image', type => 'image',
desc => 'The image' }, desc => 'The image' },
{ name => 'colormap', type => 'int8array', { name => 'colormap', type => 'bytes',
desc => 'The new colormap values', desc => 'The new colormap values' }
array => { name => 'num_bytes', type => '0 <= int32 <= 768',
desc => 'Number of bytes in the colormap array' } }
); );
%invoke = ( %invoke = (
headers => [ qw("core/gimpimage-colormap.h") ], headers => [ qw("core/gimpimage-colormap.h") ],
code => <<'CODE' code => <<'CODE'
{ {
gimp_image_set_colormap (image, colormap, num_bytes / 3, TRUE); gimp_image_set_colormap (image,
g_bytes_get_data (colormap, NULL),
g_bytes_get_size (colormap) / 3,
TRUE);
} }
CODE CODE
); );
@ -3035,10 +3037,8 @@ HELP
desc => 'The previews height' }, desc => 'The previews height' },
{ name => 'bpp', type => 'int32', { name => 'bpp', type => 'int32',
desc => 'The previews bpp' }, desc => 'The previews bpp' },
{ name => 'thumbnail_data', type => 'int8array', { name => 'thumbnail_data', type => 'bytes',
desc => 'The thumbnail data', desc => 'The thumbnail data' }
array => { name => 'thumbnail_data_count',
desc => 'The number of bytes in thumbnail data' } }
); );
%invoke = ( %invoke = (
@ -3068,9 +3068,8 @@ HELP
actual_width = gimp_temp_buf_get_width (buf); actual_width = gimp_temp_buf_get_width (buf);
actual_height = gimp_temp_buf_get_height (buf); actual_height = gimp_temp_buf_get_height (buf);
bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf)); bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf); thumbnail_data = g_bytes_new (gimp_temp_buf_get_data (buf),
thumbnail_data = g_memdup2 (gimp_temp_buf_get_data (buf), gimp_temp_buf_get_data_size (buf));
thumbnail_data_count);
gimp_temp_buf_unref (buf); gimp_temp_buf_unref (buf);
} }

View File

@ -34,10 +34,8 @@ HELP
); );
@outargs = ( @outargs = (
{ name => 'profile_data', type => 'int8array', { name => 'profile_data', type => 'bytes',
desc => "The image's serialized color profile.", desc => "The image's serialized color profile." }
array => { name => 'num_bytes',
desc => 'Number of bytes in the color_profile array' } }
); );
%invoke = ( %invoke = (
@ -54,8 +52,7 @@ HELP
data = gimp_color_profile_get_icc_profile (profile, &length); data = gimp_color_profile_get_icc_profile (profile, &length);
profile_data = g_memdup2 (data, length); profile_data = g_bytes_new (data, length);
num_bytes = length;
} }
} }
CODE CODE
@ -82,10 +79,8 @@ HELP
); );
@outargs = ( @outargs = (
{ name => 'profile_data', type => 'int8array', { name => 'profile_data', type => 'bytes',
desc => "The image's serialized color profile.", desc => "The image's serialized color profile." }
array => { name => 'num_bytes',
desc => 'Number of bytes in the color_profile array' } }
); );
%invoke = ( %invoke = (
@ -102,8 +97,7 @@ HELP
data = gimp_color_profile_get_icc_profile (profile, &length); data = gimp_color_profile_get_icc_profile (profile, &length);
profile_data = g_memdup2 (data, length); profile_data = g_bytes_new (data, length);
num_bytes = length;
} }
} }
CODE CODE
@ -128,10 +122,8 @@ HELP
@inargs = ( @inargs = (
{ name => 'image', type => 'image', { name => 'image', type => 'image',
desc => 'The image' }, desc => 'The image' },
{ name => 'color_profile', type => 'int8array', { name => 'color_profile', type => 'bytes',
desc => 'The new serialized color profile', desc => 'The new serialized color profile' }
array => { name => 'num_bytes',
desc => 'Number of bytes in the color_profile array' } }
); );
%invoke = ( %invoke = (
@ -141,8 +133,8 @@ HELP
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (color_profile, profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
num_bytes, g_bytes_get_size (color_profile),
error); error);
if (profile) if (profile)
@ -231,10 +223,8 @@ HELP
); );
@outargs = ( @outargs = (
{ name => 'profile_data', type => 'int8array', { name => 'profile_data', type => 'bytes',
desc => "The image's serialized simulation color profile.", desc => "The image's serialized simulation color profile." }
array => { name => 'num_bytes',
desc => 'Number of bytes in the color_profile array' } }
); );
%invoke = ( %invoke = (
@ -251,8 +241,7 @@ HELP
data = gimp_color_profile_get_icc_profile (profile, &length); data = gimp_color_profile_get_icc_profile (profile, &length);
profile_data = g_memdup2 (data, length); profile_data = g_bytes_new (data, length);
num_bytes = length;
} }
} }
CODE CODE
@ -274,10 +263,8 @@ HELP
@inargs = ( @inargs = (
{ name => 'image', type => 'image', { name => 'image', type => 'image',
desc => 'The image' }, desc => 'The image' },
{ name => 'color_profile', type => 'int8array', { name => 'color_profile', type => 'bytes',
desc => 'The new serialized simulation color profile', desc => 'The new serialized simulation color profile'}
array => { name => 'num_bytes',
desc => 'Number of bytes in the color_profile array' } }
); );
%invoke = ( %invoke = (
@ -287,8 +274,8 @@ HELP
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (color_profile, profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
num_bytes, g_bytes_get_size (color_profile),
error); error);
if (profile) if (profile)
@ -479,10 +466,8 @@ HELP
@inargs = ( @inargs = (
{ name => 'image', type => 'image', { name => 'image', type => 'image',
desc => 'The image' }, desc => 'The image' },
{ name => 'color_profile', type => 'int8array', { name => 'color_profile', type => 'bytes',
desc => 'The serialized color profile', desc => 'The serialized color profile' },
array => { name => 'num_bytes',
desc => 'Number of bytes in the color_profile array' } },
{ name => 'intent', type => 'enum GimpColorRenderingIntent', { name => 'intent', type => 'enum GimpColorRenderingIntent',
desc => 'Rendering intent' }, desc => 'Rendering intent' },
{ name => 'bpc', type => 'boolean', { name => 'bpc', type => 'boolean',
@ -496,8 +481,8 @@ HELP
{ {
GimpColorProfile *profile; GimpColorProfile *profile;
profile = gimp_color_profile_new_from_icc_profile (color_profile, profile = gimp_color_profile_new_from_icc_profile (g_bytes_get_data (color_profile, NULL),
num_bytes, g_bytes_get_size (color_profile),
error); error);
if (profile) if (profile)

View File

@ -192,19 +192,17 @@ HELP
desc => 'Width of the matrix (0 to reset to default matrix)' }, desc => 'Width of the matrix (0 to reset to default matrix)' },
{ name => 'height', type => 'int32', { name => 'height', type => 'int32',
desc => 'Height of the matrix (0 to reset to default matrix)' }, desc => 'Height of the matrix (0 to reset to default matrix)' },
{ name => 'matrix', type => 'int8array', { name => 'matrix', type => 'bytes',
desc => 'The matrix -- all values must be >= 1', desc => 'The matrix -- all values must be >= 1' },
array => { name => 'matrix_length', type => '1 <= int32 <= 1024',
desc => "The length of 'matrix'" }
},
); );
%invoke = ( %invoke = (
code => <<'CODE' code => <<'CODE'
{ {
if (width == 0 || height == 0 || matrix_length == width * height) if (width == 0 || height == 0 || g_bytes_get_size (matrix) == width * height)
{ {
gimp_image_convert_indexed_set_dither_matrix (matrix, width, height); gimp_image_convert_indexed_set_dither_matrix (g_bytes_get_data (matrix, NULL),
width, height);
} }
else else
{ {

View File

@ -87,9 +87,8 @@ HELP
desc => "The pattern height" }, desc => "The pattern height" },
{ name => 'bpp', type => 'int32', { name => 'bpp', type => 'int32',
desc => "The pattern bpp" }, desc => "The pattern bpp" },
{ name => 'color_bytes', type => 'int8array', { name => 'color_bytes', type => 'bytes',
desc => 'The pattern data.', desc => 'The pattern data.' }
array => { desc => 'Number of pattern bytes' } }
); );
%invoke = ( %invoke = (
@ -106,8 +105,7 @@ HELP
width = gimp_temp_buf_get_width (pattern->mask); width = gimp_temp_buf_get_width (pattern->mask);
height = gimp_temp_buf_get_height (pattern->mask); height = gimp_temp_buf_get_height (pattern->mask);
bpp = babl_format_get_bytes_per_pixel (format); bpp = babl_format_get_bytes_per_pixel (format);
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask); color_bytes = g_bytes_new (data, gimp_temp_buf_get_data_size (pattern->mask));
color_bytes = g_memdup2 (data, num_color_bytes);
gimp_temp_buf_unlock (pattern->mask, data); gimp_temp_buf_unlock (pattern->mask, data);
} }

View File

@ -656,11 +656,9 @@ HELP
desc => 'The procedure for which to install the icon' }, desc => 'The procedure for which to install the icon' },
{ name => 'icon_type', type => 'enum GimpIconType', { name => 'icon_type', type => 'enum GimpIconType',
desc => 'The type of the icon' }, desc => 'The type of the icon' },
{ name => 'icon_data', type => 'int8array', { name => 'icon_data', type => 'bytes',
desc => "The procedure's icon. The format depends on the desc => "The procedure's icon. The format depends on the
'icon_type' parameter", 'icon_type' parameter", }
array => { name => 'icon_data_length', type => '1 <= int32',
desc => "The length of 'icon-data'" } }
); );
%invoke = ( %invoke = (
@ -673,7 +671,8 @@ HELP
{ {
success = gimp_plug_in_set_proc_icon (plug_in, procedure_name, success = gimp_plug_in_set_proc_icon (plug_in, procedure_name,
icon_type, icon_type,
icon_data, icon_data_length, g_bytes_get_data (icon_data, NULL),
g_bytes_get_size (icon_data),
error); error);
} }
else else
@ -1215,10 +1214,8 @@ HELP
); );
@outargs = ( @outargs = (
{ name => 'data', type => 'int8array', void_ret => 1, { name => 'data', type => 'bytes', void_ret => 1,
desc => 'A byte array containing data', desc => 'A byte array containing data' }
array => { name => 'bytes', type => '1 <= int32',
desc => 'The number of bytes in the data' } }
); );
%invoke = ( %invoke = (
@ -1227,12 +1224,13 @@ HELP
if (gimp_is_canonical_identifier (identifier)) if (gimp_is_canonical_identifier (identifier))
{ {
const guint8 *orig_data; const guint8 *orig_data;
gint bytes;
orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager, orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager,
identifier, &bytes); identifier, &bytes);
if (orig_data) if (orig_data)
data = g_memdup2 (orig_data, bytes); data = g_bytes_new (orig_data, bytes);
else else
success = FALSE; success = FALSE;
} }
@ -1308,10 +1306,8 @@ HELP
@inargs = ( @inargs = (
{ name => 'identifier', type => 'string', non_empty => 1, { name => 'identifier', type => 'string', non_empty => 1,
desc => 'The identifier associated with data' }, desc => 'The identifier associated with data' },
{ name => 'data', type => 'int8array', { name => 'data', type => 'bytes',
desc => 'A byte array containing data', desc => 'A byte array containing data' }
array => { name => 'bytes', type => '1 <= int32',
desc => 'The number of bytes in the data' } }
); );
%invoke = ( %invoke = (
@ -1320,7 +1316,9 @@ HELP
if (gimp_is_canonical_identifier (identifier)) if (gimp_is_canonical_identifier (identifier))
{ {
gimp_plug_in_manager_set_data (gimp->plug_in_manager, gimp_plug_in_manager_set_data (gimp->plug_in_manager,
identifier, bytes, data); identifier,
g_bytes_get_size (data),
g_bytes_get_data (data, NULL));
} }
else else
{ {

View File

@ -70,6 +70,17 @@ package Gimp::CodeGen::pdb;
set_value_func => 'g_value_set_boxed ($value, $var)', set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)' }, take_value_func => 'g_value_take_boxed ($value, $var)' },
bytes => { name => 'BYTES',
gtype => 'G_TYPE_BYTES',
type => 'GBytes *',
const_type => 'GBytes *',
init_value => 'NULL',
out_annotate => '(transfer full)',
get_value_func => '$var = g_value_get_boxed ($value)',
dup_value_func => '$var = GIMP_VALUES_DUP_BYTES ($value)',
set_value_func => 'g_value_set_boxed ($value, $var)',
take_value_func => 'g_value_take_boxed ($value, $var)' },
int32array => { name => 'INT32ARRAY', int32array => { name => 'INT32ARRAY',
gtype => 'GIMP_TYPE_INT32_ARRAY', gtype => 'GIMP_TYPE_INT32_ARRAY',
type => 'gint32 *', type => 'gint32 *',
@ -83,19 +94,6 @@ package Gimp::CodeGen::pdb;
set_value_func => 'gimp_value_set_int32_array ($value, $var, $var_len)', set_value_func => 'gimp_value_set_int32_array ($value, $var, $var_len)',
take_value_func => 'gimp_value_take_int32_array ($value, $var, $var_len)' }, take_value_func => 'gimp_value_take_int32_array ($value, $var, $var_len)' },
int8array => { name => 'INT8ARRAY',
gtype => 'GIMP_TYPE_UINT8_ARRAY',
type => 'guint8 *',
const_type => 'const guint8 *',
array => 1,
init_value => 'NULL',
in_annotate => '(element-type guint8)',
out_annotate => '(element-type guint8) (transfer full)',
get_value_func => '$var = gimp_value_get_uint8_array ($value)',
dup_value_func => '$var = GIMP_VALUES_DUP_UINT8_ARRAY ($value)',
set_value_func => 'gimp_value_set_uint8_array ($value, $var, $var_len)',
take_value_func => 'gimp_value_take_uint8_array ($value, $var, $var_len)' },
floatarray => { name => 'FLOATARRAY', floatarray => { name => 'FLOATARRAY',
gtype => 'GIMP_TYPE_FLOAT_ARRAY', gtype => 'GIMP_TYPE_FLOAT_ARRAY',
type => 'gdouble *', type => 'gdouble *',

View File

@ -561,7 +561,7 @@ do_optimizations (GimpRunMode run_mode,
if (imagetype == GIMP_INDEXED) if (imagetype == GIMP_INDEXED)
{ {
palette = gimp_image_get_colormap (image, &ncolors); palette = gimp_image_get_colormap (image, NULL, &ncolors);
gimp_image_set_colormap (new_image, palette, ncolors); gimp_image_set_colormap (new_image, palette, ncolors);
} }

View File

@ -354,14 +354,14 @@ blinds_dialog (GimpProcedure *procedure,
} }
static void static void
blindsapply (GObject *config, blindsapply (GObject *config,
guchar *srow, const guchar *srow,
guchar *drow, guchar *drow,
gint width, gint width,
gint bpp, gint bpp,
guchar *bg) guchar *bg)
{ {
guchar *src; const guchar *src;
guchar *dst; guchar *dst;
gint i,j,k; gint i,j,k;
gdouble ang; gdouble ang;
@ -473,9 +473,10 @@ dialog_update_preview (GtkWidget *widget,
GimpPreview *preview = GIMP_PREVIEW (widget); GimpPreview *preview = GIMP_PREVIEW (widget);
GimpDrawable *drawable = g_object_get_data (config, "drawable"); GimpDrawable *drawable = g_object_get_data (config, "drawable");
gint y; gint y;
guchar *p; const guchar *p;
guchar *buffer; guchar *buffer;
guchar *cache; GBytes *cache;
const guchar *cache_start;
GimpRGB background; GimpRGB background;
guchar bg[4]; guchar bg[4];
gint width; gint width;
@ -491,8 +492,9 @@ dialog_update_preview (GtkWidget *widget,
gimp_preview_get_size (preview, &width, &height); gimp_preview_get_size (preview, &width, &height);
cache = gimp_drawable_get_thumbnail_data (drawable, cache = gimp_drawable_get_thumbnail_data (drawable,
width, height,
&width, &height, &bpp); &width, &height, &bpp);
p = cache; p = cache_start = g_bytes_get_data (cache, NULL);
gimp_context_get_background (&background); gimp_context_get_background (&background);
@ -569,7 +571,7 @@ dialog_update_preview (GtkWidget *widget,
else else
{ {
/* Draw line from src */ /* Draw line from src */
p = cache + p = cache_start +
(width * bpp * (dr[y] - 1)); (width * bpp * (dr[y] - 1));
} }
memcpy (buffer + y * width * bpp, memcpy (buffer + y * width * bpp,
@ -583,7 +585,7 @@ dialog_update_preview (GtkWidget *widget,
gimp_preview_draw_buffer (preview, buffer, width * bpp); gimp_preview_draw_buffer (preview, buffer, width * bpp);
g_free (buffer); g_free (buffer);
g_free (cache); g_bytes_unref (cache);
} }
/* STEP tells us how many rows/columns to gulp down in one go... */ /* STEP tells us how many rows/columns to gulp down in one go... */

View File

@ -200,16 +200,10 @@ remap_create_procedure (GimpPlugIn *plug_in,
"Mukund Sivaraman <muks@mukund.org>", "Mukund Sivaraman <muks@mukund.org>",
"June 2006"); "June 2006");
GIMP_PROC_ARG_INT (procedure, "num-colors", GIMP_PROC_ARG_BYTES (procedure, "map",
"Num colors", "Map",
"Length of 'map' argument", "Remap array for the colormap",
1, 256, 1, G_PARAM_READWRITE);
G_PARAM_READWRITE);
GIMP_PROC_ARG_UINT8_ARRAY (procedure, "map",
"Map",
"Remap array for the colormap",
G_PARAM_READWRITE);
} }
else if (! strcmp (name, PLUG_IN_PROC_SWAP)) else if (! strcmp (name, PLUG_IN_PROC_SWAP))
{ {
@ -321,13 +315,13 @@ remap_run (GimpProcedure *procedure,
if (strcmp (gimp_procedure_get_name (procedure), if (strcmp (gimp_procedure_get_name (procedure),
PLUG_IN_PROC_REMAP) == 0) PLUG_IN_PROC_REMAP) == 0)
{ {
gint n_col_args; GBytes *col_args_bytes;
const guchar *col_args; const guchar *col_args;
g_free (gimp_image_get_colormap (image, &remap->n_cols)); g_free (gimp_image_get_colormap (image, NULL, &remap->n_cols));
n_col_args = GIMP_VALUES_GET_INT (args, 0); col_args_bytes = GIMP_VALUES_GET_BYTES (args, 0);
col_args = GIMP_VALUES_GET_UINT8_ARRAY (args, 1); col_args = g_bytes_get_data (col_args_bytes, NULL);
switch (run_mode) switch (run_mode)
{ {
@ -343,7 +337,7 @@ remap_run (GimpProcedure *procedure,
break; break;
case GIMP_RUN_NONINTERACTIVE: case GIMP_RUN_NONINTERACTIVE:
if (remap->n_cols != n_col_args) if (remap->n_cols != g_bytes_get_size (col_args_bytes))
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CALLING_ERROR, GIMP_PDB_CALLING_ERROR,
NULL); NULL);
@ -381,7 +375,7 @@ remap_run (GimpProcedure *procedure,
GIMP_PDB_CALLING_ERROR, GIMP_PDB_CALLING_ERROR,
NULL); NULL);
g_free (gimp_image_get_colormap (image, &n_cols)); g_free (gimp_image_get_colormap (image, NULL, &n_cols));
if (index1 >= n_cols || index2 >= n_cols) if (index1 >= n_cols || index2 >= n_cols)
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
@ -419,7 +413,7 @@ real_remap (GimpImage *image,
gboolean valid[256]; gboolean valid[256];
gint i; gint i;
cmap = gimp_image_get_colormap (image, &ncols); cmap = gimp_image_get_colormap (image, NULL, &ncols);
g_return_val_if_fail (cmap != NULL, FALSE); g_return_val_if_fail (cmap != NULL, FALSE);
g_return_val_if_fail (ncols > 0, FALSE); g_return_val_if_fail (ncols > 0, FALSE);
@ -725,7 +719,7 @@ remap_dialog (GimpImage *image,
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
vbox, TRUE, TRUE, 0); vbox, TRUE, TRUE, 0);
cmap = gimp_image_get_colormap (image, &ncols); cmap = gimp_image_get_colormap (image, NULL, &ncols);
g_return_val_if_fail ((ncols > 0) && (ncols <= 256), FALSE); g_return_val_if_fail ((ncols > 0) && (ncols <= 256), FALSE);

View File

@ -368,8 +368,7 @@ static void p_copy_points (BenderDialog *cd,
const gdouble *floatarray); const gdouble *floatarray);
static void p_copy_yval (BenderDialog *cd, static void p_copy_yval (BenderDialog *cd,
int outline, int outline,
int argc, GBytes *bytes);
const guint8 *int8array);
static int p_save_pointfile (BenderDialog *cd, static int p_save_pointfile (BenderDialog *cd,
const gchar *filename); const gchar *filename);
@ -537,29 +536,17 @@ bender_create_procedure (GimpPlugIn *plug_in,
"{ 0.0 <= y <= 1.0 or -1 for unused point }", "{ 0.0 <= y <= 1.0 or -1 for unused point }",
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "argc-upper-val-y", GIMP_PROC_ARG_BYTES (procedure, "upper-val-y",
"Argc upper val Y", "Upper val Y",
"Argc upper val Y", "Array of 256 y freehand coords "
256, 256, 256, "{ 0 <= y <= 255 }",
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_UINT8_ARRAY (procedure, "upper-val-y", GIMP_PROC_ARG_BYTES (procedure, "lower-val-y",
"Upper val Y", "Lower val Y",
"Array of 256 y freehand coords " "Array of 256 y freehand coords "
"{ 0 <= y <= 255 }", "{ 0 <= y <= 255 }",
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "argc-lower-val-y",
"Argc lower val Y",
"Argc lower val Y",
256, 256, 256,
G_PARAM_READWRITE);
GIMP_PROC_ARG_UINT8_ARRAY (procedure, "lower-val-y",
"Lower val Y",
"Array of 256 y freehand coords "
"{ 0 <= y <= 255 }",
G_PARAM_READWRITE);
GIMP_PROC_VAL_LAYER (procedure, "bent-layer", GIMP_PROC_VAL_LAYER (procedure, "bent-layer",
"Bent layer", "Bent layer",
@ -767,11 +754,9 @@ bender_run (GimpProcedure *procedure,
GIMP_VALUES_GET_FLOAT_ARRAY (args, 12)); GIMP_VALUES_GET_FLOAT_ARRAY (args, 12));
p_copy_yval (cd, OUTLINE_UPPER, p_copy_yval (cd, OUTLINE_UPPER,
GIMP_VALUES_GET_INT (args, 13), GIMP_VALUES_GET_BYTES (args, 13));
GIMP_VALUES_GET_UINT8_ARRAY (args, 14));
p_copy_yval (cd, OUTLINE_LOWER, p_copy_yval (cd, OUTLINE_LOWER,
GIMP_VALUES_GET_INT (args, 15), GIMP_VALUES_GET_BYTES (args, 14));
GIMP_VALUES_GET_UINT8_ARRAY (args, 16));
break; break;
case GIMP_RUN_WITH_LAST_VALS: case GIMP_RUN_WITH_LAST_VALS:
@ -1094,25 +1079,22 @@ p_copy_points (BenderDialog *cd,
static void static void
p_copy_yval (BenderDialog *cd, p_copy_yval (BenderDialog *cd,
int outline, int outline,
int argc, GBytes *bytes)
const guint8 *int8array)
{ {
int j; const guint8 *array = g_bytes_get_data (bytes, NULL);
guchar fill; guchar fill = MIDDLE;
fill = MIDDLE; for (int j = 0; j < 256; j++)
{
for (j = 0; j < 256; j++) if (j < g_bytes_get_size (bytes))
{ {
if (j < argc) fill = cd->curve[outline][j] = array[j];
{ }
fill = cd->curve[outline][j] = int8array[j]; else
} {
else cd->curve[outline][j] = fill;
{ }
cd->curve[outline][j] = fill; }
}
}
} }
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */

View File

@ -865,7 +865,7 @@ save_image (GFile *file,
/* Work out whether to save as 8bit or 4bit */ /* Work out whether to save as 8bit or 4bit */
if (bpp < 32) if (bpp < 32)
{ {
g_free (gimp_image_get_colormap (image, &colors)); g_free (gimp_image_get_colormap (image, NULL, &colors));
if (colors > 15) if (colors > 15)
{ {

View File

@ -857,7 +857,7 @@ save_image (GFile *file,
case GIMP_INDEXEDA_IMAGE: case GIMP_INDEXEDA_IMAGE:
is_gif89 = TRUE; is_gif89 = TRUE;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
gimp_context_get_background (&background); gimp_context_get_background (&background);
gimp_rgb_get_uchar (&background, &bgred, &bggreen, &bgblue); gimp_rgb_get_uchar (&background, &bgred, &bggreen, &bgblue);

View File

@ -238,16 +238,10 @@ gih_create_procedure (GimpPlugIn *plug_in,
1, 1000, 1, 1, 1000, 1,
GIMP_PARAM_READWRITE); GIMP_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "dimension", GIMP_PROC_ARG_BYTES (procedure, "rank",
"Dimension", "Rank",
"Dimension of the brush pipe", "Ranks of the dimensions",
1, 4, 1, GIMP_PARAM_READWRITE);
GIMP_PARAM_READWRITE);
GIMP_PROC_ARG_UINT8_ARRAY (procedure, "rank",
"Rank",
"Ranks of the dimensions",
GIMP_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "dimension-2", GIMP_PROC_ARG_INT (procedure, "dimension-2",
"Dimension 2", "Dimension 2",
@ -280,6 +274,7 @@ gih_save (GimpProcedure *procedure,
GimpImage *orig_image; GimpImage *orig_image;
GError *error = NULL; GError *error = NULL;
gint i; gint i;
GBytes *rank_bytes;
orig_image = image; orig_image = image;
@ -402,17 +397,18 @@ gih_save (GimpProcedure *procedure,
gihparams.cellheight = GIMP_VALUES_GET_INT (args, 3); gihparams.cellheight = GIMP_VALUES_GET_INT (args, 3);
gihparams.cols = GIMP_VALUES_GET_INT (args, 4); gihparams.cols = GIMP_VALUES_GET_INT (args, 4);
gihparams.rows = GIMP_VALUES_GET_INT (args, 5); gihparams.rows = GIMP_VALUES_GET_INT (args, 5);
gihparams.dim = GIMP_VALUES_GET_INT (args, 6); rank_bytes = GIMP_VALUES_GET_BYTES (args, 6);
gihparams.dim = g_bytes_get_size (rank_bytes);
gihparams.ncells = 1; gihparams.ncells = 1;
if (GIMP_VALUES_GET_INT (args, 8) != gihparams.dim) if (GIMP_VALUES_GET_INT (args, 7) != gihparams.dim)
{ {
status = GIMP_PDB_CALLING_ERROR; status = GIMP_PDB_CALLING_ERROR;
} }
else else
{ {
const guint8 *rank = GIMP_VALUES_GET_UINT8_ARRAY (args, 7); const guint8 *rank = g_bytes_get_data (rank_bytes, NULL);
const gchar **sel = GIMP_VALUES_GET_STRV (args, 9); const gchar **sel = GIMP_VALUES_GET_STRV (args, 8);
for (i = 0; i < gihparams.dim; i++) for (i = 0; i < gihparams.dim; i++)
{ {

View File

@ -340,7 +340,7 @@ save_image (GFile *file,
} }
/* save colormap */ /* save colormap */
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
if (! print (output, error, if (! print (output, error,
"static unsigned char header_data_cmap[256][3] = {") || "static unsigned char header_data_cmap[256][3] = {") ||

View File

@ -660,7 +660,7 @@ respin_cmap (png_structp pp,
gint transparent; gint transparent;
gint cols, rows; gint cols, rows;
before = gimp_image_get_colormap (image, &colors); before = gimp_image_get_colormap (image, NULL, &colors);
/* Make sure there is something in the colormap */ /* Make sure there is something in the colormap */
if (colors == 0) if (colors == 0)
@ -1032,7 +1032,7 @@ mng_save_image (GFile *file,
guchar *palette; guchar *palette;
gint numcolors; gint numcolors;
palette = gimp_image_get_colormap (image, &numcolors); palette = gimp_image_get_colormap (image, NULL, &numcolors);
if ((numcolors != 0) && if ((numcolors != 0) &&
(mng_putchunk_plte_wrapper (handle, numcolors, (mng_putchunk_plte_wrapper (handle, numcolors,
@ -1284,7 +1284,7 @@ mng_save_image (GFile *file,
mngg.has_plte = TRUE; mngg.has_plte = TRUE;
mngg.palette = (png_colorp) mngg.palette = (png_colorp)
gimp_image_get_colormap (image, &mngg.num_palette); gimp_image_get_colormap (image, NULL, &mngg.num_palette);
bit_depth = get_bit_depth_for_palette (mngg.num_palette); bit_depth = get_bit_depth_for_palette (mngg.num_palette);
break; break;

View File

@ -1121,7 +1121,8 @@ save_image (GFile *file,
switch (drawable_type) switch (drawable_type)
{ {
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
if (colors > 16) if (colors > 16)
{ {
pcx_header.bpp = 8; pcx_header.bpp = 8;

View File

@ -1606,6 +1606,7 @@ save_image (GFile *file,
file_format = gimp_drawable_get_format (drawable); file_format = gimp_drawable_get_format (drawable);
pngg.has_plte = TRUE; pngg.has_plte = TRUE;
pngg.palette = (png_colorp) gimp_image_get_colormap (image, pngg.palette = (png_colorp) gimp_image_get_colormap (image,
NULL,
&pngg.num_palette); &pngg.num_palette);
if (optimize_palette) if (optimize_palette)
bit_depth = get_bit_depth_for_palette (pngg.num_palette); bit_depth = get_bit_depth_for_palette (pngg.num_palette);
@ -2185,7 +2186,7 @@ respin_cmap (png_structp pp,
gint colors; gint colors;
guchar *before; guchar *before;
before = gimp_image_get_colormap (image, &colors); before = gimp_image_get_colormap (image, NULL, &colors);
buffer = gimp_drawable_get_buffer (drawable); buffer = gimp_drawable_get_buffer (drawable);
/* Make sure there is something in the colormap. /* Make sure there is something in the colormap.

View File

@ -1820,7 +1820,7 @@ save_image (GFile *file,
guchar *cmap; guchar *cmap;
gint num_colors; gint num_colors;
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
if (file_type == FILE_TYPE_PBM) if (file_type == FILE_TYPE_PBM)
{ {

View File

@ -2719,6 +2719,7 @@ save_ps_preview (GOutputStream *output,
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
cmap = gimp_image_get_colormap (gimp_item_get_image (GIMP_ITEM (drawable)), cmap = gimp_image_get_colormap (gimp_item_get_image (GIMP_ITEM (drawable)),
NULL,
&ncols); &ncols);
format = gimp_drawable_get_format (drawable); format = gimp_drawable_get_format (drawable);
break; break;
@ -3032,7 +3033,7 @@ save_bw (GOutputStream *output,
"level", &level2, "level", &level2,
NULL); NULL);
cmap = gimp_image_get_colormap (image, &ncols); cmap = gimp_image_get_colormap (image, NULL, &ncols);
buffer = gimp_drawable_get_buffer (drawable); buffer = gimp_drawable_get_buffer (drawable);
format = gimp_drawable_get_format (drawable); format = gimp_drawable_get_format (drawable);
@ -3221,7 +3222,7 @@ save_index (GOutputStream *output,
"level", &level2, "level", &level2,
NULL); NULL);
cmap = cmap_start = gimp_image_get_colormap (image, &ncols); cmap = cmap_start = gimp_image_get_colormap (image, NULL, &ncols);
ct = coltab; ct = coltab;
bw = 1; bw = 1;
@ -4029,4 +4030,4 @@ resolution_change_callback (GtkWidget *adjustment,
NULL); NULL);
return TRUE; return TRUE;
} }

View File

@ -1324,7 +1324,7 @@ save_image (GFile *file,
g_return_val_if_fail (bpc * n_components == bpp, FALSE); g_return_val_if_fail (bpc * n_components == bpp, FALSE);
if (gimp_drawable_is_indexed (drawable)) if (gimp_drawable_is_indexed (drawable))
cmap = gimp_image_get_colormap (image, &palsize); cmap = gimp_image_get_colormap (image, NULL, &palsize);
width = gegl_buffer_get_width (buffer); width = gegl_buffer_get_width (buffer);
height = gegl_buffer_get_height (buffer); height = gegl_buffer_get_height (buffer);

View File

@ -1529,7 +1529,7 @@ save_index (FILE *ofp,
} }
else else
{ {
cmap = gimp_image_get_colormap (image, &ncols); cmap = gimp_image_get_colormap (image, NULL, &ncols);
for (j = 0; j < ncols; j++) for (j = 0; j < ncols; j++)
{ {

View File

@ -1244,7 +1244,7 @@ save_image (GFile *file,
if (dtype == GIMP_INDEXED_IMAGE) if (dtype == GIMP_INDEXED_IMAGE)
{ {
gimp_cmap = gimp_image_get_colormap (image, &num_colors); gimp_cmap = gimp_image_get_colormap (image, NULL, &num_colors);
header[1] = 1; /* cmap type */ header[1] = 1; /* cmap type */
header[2] = rle ? 9 : 1; header[2] = rle ? 9 : 1;
@ -1255,7 +1255,7 @@ save_image (GFile *file,
} }
else if (dtype == GIMP_INDEXEDA_IMAGE) else if (dtype == GIMP_INDEXEDA_IMAGE)
{ {
gimp_cmap = gimp_image_get_colormap (image, &num_colors); gimp_cmap = gimp_image_get_colormap (image, NULL, &num_colors);
header[1] = 1; /* cmap type */ header[1] = 1; /* cmap type */
header[2] = rle ? 9 : 1; header[2] = rle ? 9 : 1;

View File

@ -1007,7 +1007,7 @@ save_image (GFile *file,
g_printerr ("%s: save_image '%s'\n", G_STRFUNC, prefix); g_printerr ("%s: save_image '%s'\n", G_STRFUNC, prefix);
#endif #endif
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
if (! gimp_drawable_is_indexed (drawable) || colors > 2) if (! gimp_drawable_is_indexed (drawable) || colors > 2)
{ {

View File

@ -790,7 +790,7 @@ save_image (GFile *file,
if (indexed) if (indexed)
{ {
guchar *cmap = gimp_image_get_colormap (image, &ncolors); guchar *cmap = gimp_image_get_colormap (image, NULL, &ncolors);
guchar *c; guchar *c;
c = cmap; c = cmap;

View File

@ -2422,7 +2422,7 @@ save_index (GOutputStream *output,
else else
{ {
vclass = 3; vclass = 3;
cmap = gimp_image_get_colormap (image, &ncolors); cmap = gimp_image_get_colormap (image, NULL, &ncolors);
for (j = 0; j < ncolors; j++) for (j = 0; j < ncolors; j++)
{ {

View File

@ -463,7 +463,7 @@ grid (GimpImage *image,
break; break;
case GIMP_INDEXED: case GIMP_INDEXED:
cmap = gimp_image_get_colormap (image, &ncolors); cmap = gimp_image_get_colormap (image, NULL, &ncolors);
hcolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.hcolor); hcolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.hcolor);
vcolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.vcolor); vcolor[0] = best_cmap_match (cmap, ncolors, &grid_cfg.vcolor);

View File

@ -524,7 +524,7 @@ jigsaw (GObject *config,
gint width; gint width;
gint height; gint height;
gint bytes; gint bytes;
gint buffer_size; gsize buffer_size;
gint x; gint x;
gint y; gint y;
gint blend_lines; gint blend_lines;
@ -537,10 +537,13 @@ jigsaw (GObject *config,
if (preview) if (preview)
{ {
GBytes *buffer_bytes;
gimp_preview_get_size (preview, &width, &height); gimp_preview_get_size (preview, &width, &height);
buffer = gimp_drawable_get_thumbnail_data (drawable, buffer_bytes = gimp_drawable_get_thumbnail_data (drawable,
&width, &height, &bytes); width, height,
buffer_size = bytes * width * height; &width, &height, &bytes);
buffer = g_bytes_unref_to_data (buffer_bytes, &buffer_size);
} }
else else
{ {

View File

@ -397,7 +397,7 @@ tile (GimpImage *image,
guchar *cmap; guchar *cmap;
gint ncols; gint ncols;
cmap = gimp_image_get_colormap (image, &ncols); cmap = gimp_image_get_colormap (image, NULL, &ncols);
gimp_image_set_colormap (*new_image, cmap, ncols); gimp_image_set_colormap (*new_image, cmap, ncols);
g_free (cmap); g_free (cmap);
} }

View File

@ -238,7 +238,7 @@ save_image (GFile *file,
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
format = gimp_drawable_get_format (drawable); format = gimp_drawable_get_format (drawable);
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
MapSize = 4 * colors; MapSize = 4 * colors;
if (drawable_type == GIMP_INDEXEDA_IMAGE) if (drawable_type == GIMP_INDEXEDA_IMAGE)

View File

@ -911,7 +911,7 @@ write_layer (FILE *fp,
if (basetype == GIMP_INDEXED) if (basetype == GIMP_INDEXED)
{ {
palette = gimp_image_get_colormap (image, &colors); palette = gimp_image_get_colormap (image, NULL, &colors);
if (type == GIMP_INDEXEDA_IMAGE) if (type == GIMP_INDEXEDA_IMAGE)
{ {
@ -1238,7 +1238,7 @@ write_volume_mipmaps (FILE *fp,
format = babl_format ("R'G'B'A u8"); format = babl_format ("R'G'B'A u8");
if (gimp_image_get_base_type (image) == GIMP_INDEXED) if (gimp_image_get_base_type (image) == GIMP_INDEXED)
palette = gimp_image_get_colormap (image, &colors); palette = gimp_image_get_colormap (image, NULL, &colors);
offset = 0; offset = 0;
for (i = 0, list = layers; for (i = 0, list = layers;
@ -1691,7 +1691,7 @@ write_image (FILE *fp,
(pixel_format == DDS_FORMAT_DEFAULT) && (pixel_format == DDS_FORMAT_DEFAULT) &&
(compression == DDS_COMPRESS_NONE)) (compression == DDS_COMPRESS_NONE))
{ {
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
for (i = 0; i < colors; ++i) for (i = 0; i < colors; ++i)
{ {

View File

@ -747,7 +747,7 @@ save_image (GFile *file,
case GIMP_INDEXED: case GIMP_INDEXED:
max = MAXDIFF; max = MAXDIFF;
bg = 0; bg = 0;
cmap = gimp_image_get_colormap (image, &colors); cmap = gimp_image_get_colormap (image, NULL, &colors);
for (i = 0; i < MIN (colors, 256); i++) for (i = 0; i < MIN (colors, 256); i++)
{ {
cm[i*3+0] = cmap[i*3+0]; cm[i*3+0] = cmap[i*3+0];

View File

@ -370,7 +370,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
if (gimp_drawable_is_indexed (layer)) if (gimp_drawable_is_indexed (layer))
{ {
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
gimp_image_set_colormap (tmp_image, cmap, num_colors); gimp_image_set_colormap (tmp_image, cmap, num_colors);
g_free (cmap); g_free (cmap);
} }
@ -403,7 +403,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
GIMP_CONVERT_PALETTE_GENERATE, GIMP_CONVERT_PALETTE_GENERATE,
1 << bpp, TRUE, FALSE, "dummy"); 1 << bpp, TRUE, FALSE, "dummy");
cmap = gimp_image_get_colormap (tmp_image, &num_colors); cmap = gimp_image_get_colormap (tmp_image, NULL, &num_colors);
if (num_colors == (1 << bpp) && if (num_colors == (1 << bpp) &&
! ico_cmap_contains_black (cmap, num_colors)) ! ico_cmap_contains_black (cmap, num_colors))
@ -414,7 +414,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
if (gimp_drawable_is_indexed (layer)) if (gimp_drawable_is_indexed (layer))
{ {
g_free (cmap); g_free (cmap);
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
gimp_image_set_colormap (tmp_image, cmap, num_colors); gimp_image_set_colormap (tmp_image, cmap, num_colors);
} }
else if (gimp_drawable_is_gray (layer)) else if (gimp_drawable_is_gray (layer))
@ -470,7 +470,7 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
guchar *cmap; guchar *cmap;
gint num_colors; gint num_colors;
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
gimp_image_set_colormap (tmp_image, cmap, num_colors); gimp_image_set_colormap (tmp_image, cmap, num_colors);
g_free (cmap); g_free (cmap);
} }

View File

@ -737,7 +737,7 @@ ico_image_get_reduced_buf (GimpDrawable *layer,
guchar *cmap; guchar *cmap;
gint num_colors; gint num_colors;
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
gimp_image_set_colormap (tmp_image, cmap, num_colors); gimp_image_set_colormap (tmp_image, cmap, num_colors);
g_free (cmap); g_free (cmap);
} }
@ -768,7 +768,7 @@ ico_image_get_reduced_buf (GimpDrawable *layer,
GIMP_CONVERT_PALETTE_GENERATE, GIMP_CONVERT_PALETTE_GENERATE,
1 << bpp, TRUE, FALSE, "dummy"); 1 << bpp, TRUE, FALSE, "dummy");
cmap = gimp_image_get_colormap (tmp_image, num_colors); cmap = gimp_image_get_colormap (tmp_image, NULL, num_colors);
if (*num_colors == (1 << bpp) && if (*num_colors == (1 << bpp) &&
! ico_cmap_contains_black (cmap, *num_colors)) ! ico_cmap_contains_black (cmap, *num_colors))
@ -780,7 +780,7 @@ ico_image_get_reduced_buf (GimpDrawable *layer,
if (gimp_drawable_is_indexed (layer)) if (gimp_drawable_is_indexed (layer))
{ {
g_free (cmap); g_free (cmap);
cmap = gimp_image_get_colormap (image, num_colors); cmap = gimp_image_get_colormap (image, NULL, num_colors);
gimp_image_set_colormap (tmp_image, cmap, *num_colors); gimp_image_set_colormap (tmp_image, cmap, *num_colors);
} }
else if (gimp_drawable_is_gray (layer)) else if (gimp_drawable_is_gray (layer))
@ -807,7 +807,7 @@ ico_image_get_reduced_buf (GimpDrawable *layer,
GIMP_CONVERT_PALETTE_GENERATE, GIMP_CONVERT_PALETTE_GENERATE,
(1<<bpp) - 1, TRUE, FALSE, "dummy"); (1<<bpp) - 1, TRUE, FALSE, "dummy");
g_free (cmap); g_free (cmap);
cmap = gimp_image_get_colormap (tmp_image, num_colors); cmap = gimp_image_get_colormap (tmp_image, NULL, num_colors);
} }
gimp_image_convert_rgb (tmp_image); gimp_image_convert_rgb (tmp_image);

View File

@ -1270,7 +1270,7 @@ load_resource_1046 (const PSDimageres *res_a,
/* FIXME - check that we have indexed image */ /* FIXME - check that we have indexed image */
if (index_count && index_count < 256) if (index_count && index_count < 256)
{ {
cmap = gimp_image_get_colormap (image, &cmap_count); cmap = gimp_image_get_colormap (image, NULL, &cmap_count);
if (cmap && index_count < cmap_count) if (cmap && index_count < cmap_count)
gimp_image_set_colormap (image, cmap, index_count); gimp_image_set_colormap (image, cmap, index_count);
g_free (cmap); g_free (cmap);

View File

@ -633,7 +633,7 @@ save_color_mode_data (GOutputStream *output,
case GIMP_INDEXED: case GIMP_INDEXED:
IFDBG(1) g_debug ("\tImage type: INDEXED"); IFDBG(1) g_debug ("\tImage type: INDEXED");
cmap = gimp_image_get_colormap (image, &nColors); cmap = gimp_image_get_colormap (image, NULL, &nColors);
IFDBG(1) g_debug ("\t\tLength of colormap returned by gimp_image_get_colormap: %d", nColors); IFDBG(1) g_debug ("\t\tLength of colormap returned by gimp_image_get_colormap: %d", nColors);
if (nColors == 0) if (nColors == 0)

View File

@ -563,7 +563,7 @@ save_layer (TIFF *tif,
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE: case GIMP_INDEXEDA_IMAGE:
cmap = gimp_image_get_colormap (image, &num_colors); cmap = gimp_image_get_colormap (image, NULL, &num_colors);
if (num_colors == 2 || num_colors == 1) if (num_colors == 2 || num_colors == 1)
{ {

View File

@ -501,7 +501,7 @@ image_is_monochrome (GimpImage *image)
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
colors = gimp_image_get_colormap (image, &num_colors); colors = gimp_image_get_colormap (image, NULL, &num_colors);
if (colors) if (colors)
{ {

View File

@ -816,7 +816,7 @@ print_preview_get_thumbnail (GimpDrawable *drawable,
{ {
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_format_t format; cairo_format_t format;
guchar *data; GBytes *data;
guchar *dest; guchar *dest;
const guchar *src; const guchar *src;
gint src_stride; gint src_stride;
@ -828,6 +828,7 @@ print_preview_get_thumbnail (GimpDrawable *drawable,
g_return_val_if_fail (height > 0 && height <= 1024, NULL); g_return_val_if_fail (height > 0 && height <= 1024, NULL);
data = gimp_drawable_get_thumbnail_data (drawable, data = gimp_drawable_get_thumbnail_data (drawable,
width, height,
&width, &height, &bpp); &width, &height, &bpp);
switch (bpp) switch (bpp)
@ -849,7 +850,7 @@ print_preview_get_thumbnail (GimpDrawable *drawable,
surface = cairo_image_surface_create (format, width, height); surface = cairo_image_surface_create (format, width, height);
src = data; src = g_bytes_get_data (data, NULL);
src_stride = width * bpp; src_stride = width * bpp;
dest = cairo_image_surface_get_data (surface); dest = cairo_image_surface_get_data (surface);
@ -904,7 +905,7 @@ print_preview_get_thumbnail (GimpDrawable *drawable,
dest += dest_stride; dest += dest_stride;
} }
g_free (data); g_bytes_unref (data);
cairo_surface_mark_dirty (surface); cairo_surface_mark_dirty (surface);

View File

@ -971,7 +971,7 @@ script_fu_marshal_procedure_call (scheme *sc,
debug_vector (sc, vector, "%ld"); debug_vector (sc, vector, "%ld");
} }
} }
else if (GIMP_VALUE_HOLDS_UINT8_ARRAY (&value)) else if (G_VALUE_HOLDS (&value, G_TYPE_BYTES))
{ {
vector = sc->vptr->pair_car (a); vector = sc->vptr->pair_car (a);
if (! sc->vptr->is_vector (vector)) if (! sc->vptr->is_vector (vector))
@ -980,10 +980,7 @@ script_fu_marshal_procedure_call (scheme *sc,
{ {
guint8 *array; guint8 *array;
n_elements = GIMP_VALUES_GET_INT (args, i - 1); n_elements = sc->vptr->vector_length (vector);
if (n_elements > sc->vptr->vector_length (vector))
return script_length_error_in_vector (sc, i, proc_name, n_elements, vector);
array = g_new0 (guint8, n_elements); array = g_new0 (guint8, n_elements);
@ -1000,7 +997,7 @@ script_fu_marshal_procedure_call (scheme *sc,
array[j] = (guint8) sc->vptr->ivalue (v_element); array[j] = (guint8) sc->vptr->ivalue (v_element);
} }
gimp_value_take_uint8_array (&value, array, n_elements); g_value_take_boxed (&value, g_bytes_new_take (array, n_elements));
debug_vector (sc, vector, "%ld"); debug_vector (sc, vector, "%ld");
} }
@ -1466,11 +1463,12 @@ script_fu_marshal_procedure_call (scheme *sc,
return_val = sc->vptr->cons (sc, vector, return_val); return_val = sc->vptr->cons (sc, vector, return_val);
} }
else if (GIMP_VALUE_HOLDS_UINT8_ARRAY (value)) else if (G_VALUE_HOLDS (value, G_TYPE_BYTES))
{ {
gint32 n = GIMP_VALUES_GET_INT (values, i); GBytes *v_bytes = g_value_get_boxed (value);
const guint8 *v = gimp_value_get_uint8_array (value); const guint8 *v = g_bytes_get_data (v_bytes, NULL);
pointer vector = sc->vptr->mk_vector (sc, n); gsize n = g_bytes_get_size (v_bytes);
pointer vector = sc->vptr->mk_vector (sc, n);
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {

View File

@ -3,7 +3,7 @@
; ;
; Change the colormap of an image to the colors in a specified palette. ; Change the colormap of an image to the colors in a specified palette.
; Included is script-fu-make-cmap-array (available for use in scripts) which ; Included is script-fu-make-cmap-array (available for use in scripts) which
; returns an INT8ARRAY containing the colors from a specified palette. ; returns a GBytes containing the colors from a specified palette.
; This array can be used as the cmap argument for gimp-image-set-colormap. ; This array can be used as the cmap argument for gimp-image-set-colormap.
; GIMP - The GNU Image Manipulation Program ; GIMP - The GNU Image Manipulation Program