app: add gimp_babl_compat_u8_format() instead of having this code 5 times
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
|
||||
#include "gimp-gegl-types.h"
|
||||
|
||||
#include "gimp-babl.h"
|
||||
#include "gimp-babl-compat.h"
|
||||
|
||||
|
||||
@ -66,3 +67,17 @@ gimp_babl_format_get_image_type (const Babl *format)
|
||||
|
||||
g_return_val_if_reached (-1);
|
||||
}
|
||||
|
||||
const Babl *
|
||||
gimp_babl_compat_u8_format (const Babl *format)
|
||||
{
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
|
||||
/* indexed images only exist in u8, return the same format */
|
||||
if (babl_format_is_palette (format))
|
||||
return format;
|
||||
|
||||
return gimp_babl_format (gimp_babl_format_get_base_type (format),
|
||||
GIMP_PRECISION_U8,
|
||||
babl_format_has_alpha (format));
|
||||
}
|
||||
|
@ -24,5 +24,7 @@
|
||||
|
||||
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
|
||||
|
||||
const Babl * gimp_babl_compat_u8_format (const Babl *format);
|
||||
|
||||
|
||||
#endif /* __GIMP_BABL_COMPAT_H__ */
|
||||
|
@ -277,10 +277,7 @@ drawable_bpp_invoker (GimpProcedure *procedure,
|
||||
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));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
bpp = babl_format_get_bytes_per_pixel (format);
|
||||
@ -614,10 +611,7 @@ drawable_get_pixel_invoker (GimpProcedure *procedure,
|
||||
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));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
||||
@ -671,10 +665,7 @@ drawable_set_pixel_invoker (GimpProcedure *procedure,
|
||||
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));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "plug-in-types.h"
|
||||
|
||||
#include "gegl/gimp-babl.h"
|
||||
#include "gegl/gimp-babl-compat.h"
|
||||
#include "gegl/gimp-gegl-tile-compat.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
@ -313,12 +314,9 @@ gimp_plug_in_handle_tile_put (GimpPlugIn *plug_in,
|
||||
|
||||
format = gegl_buffer_get_format (buffer);
|
||||
|
||||
if (! gimp_plug_in_precision_enabled (plug_in) &&
|
||||
! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
|
||||
if (! gimp_plug_in_precision_enabled (plug_in))
|
||||
{
|
||||
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
|
||||
GIMP_PRECISION_U8,
|
||||
babl_format_has_alpha (format));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
if (tile_data.use_shm)
|
||||
@ -412,12 +410,9 @@ gimp_plug_in_handle_tile_get (GimpPlugIn *plug_in,
|
||||
|
||||
format = gegl_buffer_get_format (buffer);
|
||||
|
||||
if (! gimp_plug_in_precision_enabled (plug_in) &&
|
||||
! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
|
||||
if (! gimp_plug_in_precision_enabled (plug_in))
|
||||
{
|
||||
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
|
||||
GIMP_PRECISION_U8,
|
||||
babl_format_has_alpha (format));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
tile_size = (babl_format_get_bytes_per_pixel (format) *
|
||||
|
@ -498,10 +498,7 @@ HELP
|
||||
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));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
bpp = babl_format_get_bytes_per_pixel (format);
|
||||
@ -628,10 +625,7 @@ HELP
|
||||
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));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
|
||||
@ -682,10 +676,7 @@ HELP
|
||||
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));
|
||||
format = gimp_babl_compat_u8_format (format);
|
||||
}
|
||||
|
||||
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
|
||||
|
Reference in New Issue
Block a user