pdb: use compat formats for drawable-get-pixel and drawable-set-pixel
unless the plug-in is precision-aware.
This commit is contained in:
@ -606,12 +606,22 @@ drawable_get_pixel_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
if (success)
|
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)) &&
|
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
||||||
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
|
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
|
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
|
||||||
x_coord, y_coord, NULL, pixel,
|
x_coord, y_coord, NULL, pixel, format,
|
||||||
gimp_drawable_get_format (drawable),
|
|
||||||
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -653,16 +663,26 @@ drawable_set_pixel_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
if (success)
|
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) &&
|
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
|
||||||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||||
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
||||||
y_coord < gimp_item_get_height (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_buffer_set (gimp_drawable_get_buffer (drawable),
|
||||||
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
|
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
|
||||||
1.0, gimp_drawable_get_format (drawable),
|
1.0, format, pixel, GEGL_AUTO_ROWSTRIDE);
|
||||||
pixel, GEGL_AUTO_ROWSTRIDE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
|
@ -620,12 +620,22 @@ HELP
|
|||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
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)) &&
|
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
||||||
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
|
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
|
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
|
||||||
x_coord, y_coord, NULL, pixel,
|
x_coord, y_coord, NULL, pixel, format,
|
||||||
gimp_drawable_get_format (drawable),
|
|
||||||
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -664,16 +674,26 @@ HELP
|
|||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
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) &&
|
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
|
||||||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||||
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
||||||
y_coord < gimp_item_get_height (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_buffer_set (gimp_drawable_get_buffer (drawable),
|
||||||
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
|
GEGL_RECTANGLE (x_coord, y_coord, 1, 1),
|
||||||
1.0, gimp_drawable_get_format (drawable),
|
1.0, format, pixel, GEGL_AUTO_ROWSTRIDE);
|
||||||
pixel, GEGL_AUTO_ROWSTRIDE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
|
Reference in New Issue
Block a user