app: use gimp_drawable_get_base_type() instead of GIMP_IMAGE_TYPE_BASE_TYPE()

This commit is contained in:
Michael Natterer 2012-04-07 01:51:08 +02:00
parent f6f7d53020
commit 2b18645fb5
9 changed files with 29 additions and 34 deletions

View File

@ -99,14 +99,11 @@ gimp_drawable_get_preview (GimpViewable *viewable,
gint
gimp_drawable_preview_bytes (GimpDrawable *drawable)
{
GimpImageBaseType base_type;
gint bytes = 0;
gint bytes = 0;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
switch (base_type)
switch (gimp_drawable_get_base_type (drawable))
{
case GIMP_RGB:
case GIMP_GRAY:
@ -151,7 +148,7 @@ gimp_drawable_get_sub_preview (GimpDrawable *drawable,
if (! image->gimp->config->layer_previews)
return NULL;
if (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)) == GIMP_INDEXED)
if (gimp_drawable_is_indexed (drawable))
return gimp_drawable_indexed_preview (drawable,
gimp_drawable_get_colormap (drawable),
src_x, src_y, src_width, src_height,

View File

@ -1156,8 +1156,6 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
GimpImageBaseType new_base_type,
gboolean push_undo)
{
GimpImageType type;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (dest_image == NULL || GIMP_IS_IMAGE (dest_image));
g_return_if_fail (new_base_type != GIMP_INDEXED || GIMP_IS_IMAGE (dest_image));
@ -1165,9 +1163,7 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
type = gimp_drawable_type (drawable);
g_return_if_fail (new_base_type != GIMP_IMAGE_TYPE_BASE_TYPE (type));
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable));
GIMP_DRAWABLE_GET_CLASS (drawable)->convert_type (drawable, dest_image,
new_base_type, push_undo);
@ -1665,7 +1661,7 @@ gimp_drawable_type_with_alpha (const GimpDrawable *drawable)
return GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
}
GimpImageType
GimpImageBaseType
gimp_drawable_get_base_type (const GimpDrawable *drawable)
{
const Babl *format;

View File

@ -226,7 +226,7 @@ const Babl * gimp_drawable_get_format_without_alpha
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type_with_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_get_base_type (const GimpDrawable *drawable);
GimpImageBaseType gimp_drawable_get_base_type (const GimpDrawable *drawable);
gboolean gimp_drawable_is_rgb (const GimpDrawable *drawable);
gboolean gimp_drawable_is_gray (const GimpDrawable *drawable);
gboolean gimp_drawable_is_indexed (const GimpDrawable *drawable);

View File

@ -814,7 +814,7 @@ gimp_group_layer_estimate_memsize (const GimpDrawable *drawable,
child_height);
}
base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
base_type = gimp_drawable_get_base_type (drawable);
memsize += gimp_projection_estimate_memsize (base_type, width, height);
@ -888,7 +888,7 @@ gimp_group_layer_get_format (GimpProjectable *projectable)
if (private->convert_format)
return private->convert_format;
base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (projectable)));
base_type = gimp_drawable_get_base_type (GIMP_DRAWABLE (projectable));
return get_projection_format (projectable, base_type);
}

View File

@ -74,7 +74,7 @@ gimp_group_layer_undo_constructed (GObject *object)
break;
case GIMP_UNDO_GROUP_LAYER_CONVERT:
group_layer_undo->prev_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (group)));
group_layer_undo->prev_type = gimp_drawable_get_base_type (GIMP_DRAWABLE (group));
break;
default:
@ -119,7 +119,7 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
{
GimpImageBaseType type;
type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (group)));
type = gimp_drawable_get_base_type (GIMP_DRAWABLE (group));
gimp_drawable_convert_type (GIMP_DRAWABLE (group), NULL,
group_layer_undo->prev_type, FALSE);
group_layer_undo->prev_type = type;

View File

@ -174,7 +174,7 @@ gimp_image_new_from_drawable (Gimp *gimp,
item = GIMP_ITEM (drawable);
image = gimp_item_get_image (item);
type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
type = gimp_drawable_get_base_type (drawable);
new_image = gimp_create_image (gimp,
gimp_item_get_width (item),
@ -313,37 +313,39 @@ gimp_image_new_from_pixbuf (Gimp *gimp,
GdkPixbuf *pixbuf,
const gchar *layer_name)
{
GimpImageType image_type;
GimpImage *new_image;
GimpLayer *layer;
GimpImage *new_image;
GimpLayer *layer;
GimpImageBaseType base_type;
gboolean has_alpha = FALSE;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
switch (gdk_pixbuf_get_n_channels (pixbuf))
{
case 1: image_type = GIMP_GRAY_IMAGE; break;
case 2: image_type = GIMP_GRAYA_IMAGE; break;
case 3: image_type = GIMP_RGB_IMAGE; break;
case 4: image_type = GIMP_RGBA_IMAGE; break;
case 2: has_alpha = TRUE;
case 1: base_type = GIMP_GRAY;
break;
case 4: has_alpha = TRUE;
case 3: base_type = GIMP_RGB;
break;
default:
g_return_val_if_reached (NULL);
break;
}
new_image = gimp_create_image (gimp,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
GIMP_IMAGE_TYPE_BASE_TYPE (image_type),
base_type,
FALSE);
gimp_image_undo_disable (new_image);
layer = gimp_layer_new_from_pixbuf (pixbuf, new_image,
gimp_image_get_format (new_image,
image_type),
gimp_image_get_layer_format (new_image,
has_alpha),
layer_name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);

View File

@ -611,7 +611,7 @@ gimp_layer_convert (GimpItem *item,
GimpImageBaseType old_base_type;
GimpImageBaseType new_base_type;
old_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
old_base_type = gimp_drawable_get_base_type (drawable);
new_base_type = gimp_image_base_type (dest_image);
if (old_base_type != new_base_type)

View File

@ -912,7 +912,7 @@ image_add_layer_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (layer), image, error) &&
gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
gimp_drawable_get_base_type (GIMP_DRAWABLE (layer)),
error))
{
success = gimp_image_add_layer (image, layer,
@ -951,7 +951,7 @@ image_insert_layer_invoker (GimpProcedure *procedure,
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (layer), image, error) &&
gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
gimp_drawable_get_base_type (GIMP_DRAWABLE (layer)),
error) &&
(parent == NULL ||
(gimp_pdb_item_is_in_tree (GIMP_ITEM (parent), image, FALSE, error) &&

View File

@ -1053,7 +1053,7 @@ sub image_add_layer {
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (layer), image, error) &&
gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
gimp_drawable_get_base_type (GIMP_DRAWABLE (layer)),
error))
{
success = gimp_image_add_layer (image, layer,
@ -1100,7 +1100,7 @@ HELP
{
if (gimp_pdb_item_is_floating (GIMP_ITEM (layer), image, error) &&
gimp_pdb_image_is_base_type (image,
GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (GIMP_DRAWABLE (layer))),
gimp_drawable_get_base_type (GIMP_DRAWABLE (layer)),
error) &&
(parent == NULL ||
(gimp_pdb_item_is_in_tree (GIMP_ITEM (parent), image, FALSE, error) &&