[gimp/goat-invasion] pdb: use compat formats for drawable-get-pixel and drawable-set-pixel
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion] pdb: use compat formats for drawable-get-pixel and drawable-set-pixel
- Date: Wed, 25 Apr 2012 11:35:14 +0000 (UTC)
commit 29684841eae09f2df16e0ffc9f1825678b523a94
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 25 13:34:30 2012 +0200
pdb: use compat formats for drawable-get-pixel and drawable-set-pixel
unless the plug-in is precision-aware.
app/pdb/drawable-cmds.c | 30 +++++++++++++++++++++++++-----
tools/pdbgen/pdb/drawable.pdb | 30 +++++++++++++++++++++++++-----
2 files changed, 50 insertions(+), 10 deletions(-)
---
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index ed0178a..cc047c6 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -606,12 +606,22 @@ drawable_get_pixel_invoker (GimpProcedure *procedure,
if (success)
{
+ const Babl *format = gimp_drawable_get_format (drawable);
+
+ if (! gimp->plug_in_manager->current_plug_in ||
+ ! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
+ {
+ if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+ }
+
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
- x_coord, y_coord, NULL, pixel,
- gimp_drawable_get_format (drawable),
+ x_coord, y_coord, NULL, pixel, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
}
else
@@ -653,16 +663,26 @@ drawable_set_pixel_invoker (GimpProcedure *procedure,
if (success)
{
+ const Babl *format = gimp_drawable_get_format (drawable);
+
+ if (! gimp->plug_in_manager->current_plug_in ||
+ ! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
+ {
+ if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+ }
+
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), 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 == gimp_drawable_bytes (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),
- 1.0, gimp_drawable_get_format (drawable),
- pixel, GEGL_AUTO_ROWSTRIDE);
+ 1.0, format, pixel, GEGL_AUTO_ROWSTRIDE);
}
else
success = FALSE;
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index 4735b12..8e098e5 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -620,12 +620,22 @@ HELP
%invoke = (
code => <<'CODE'
{
+ const Babl *format = gimp_drawable_get_format (drawable);
+
+ if (! gimp->plug_in_manager->current_plug_in ||
+ ! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
+ {
+ if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+ }
+
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
- x_coord, y_coord, NULL, pixel,
- gimp_drawable_get_format (drawable),
+ x_coord, y_coord, NULL, pixel, format,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
}
else
@@ -664,16 +674,26 @@ HELP
%invoke = (
code => <<'CODE'
{
+ const Babl *format = gimp_drawable_get_format (drawable);
+
+ if (! gimp->plug_in_manager->current_plug_in ||
+ ! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
+ {
+ if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+ }
+
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), 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 == gimp_drawable_bytes (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),
- 1.0, gimp_drawable_get_format (drawable),
- pixel, GEGL_AUTO_ROWSTRIDE);
+ 1.0, format, pixel, GEGL_AUTO_ROWSTRIDE);
}
else
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]