mirror of https://github.com/GNOME/gimp.git
Add gimp_drawable_convert_rgb() and gimp_drawable_convert_grayscale()
The new functions reall convert the drawable this time, using the previously renamed convert_tiles functions. Remove tile manager fiddling from all callers and leave it there only for converting to indexed.
This commit is contained in:
parent
83c79bad5d
commit
f2f741a26e
|
@ -435,21 +435,7 @@ gimp_channel_convert (GimpItem *item,
|
|||
|
||||
if (! gimp_drawable_is_gray (drawable))
|
||||
{
|
||||
TileManager *new_tiles;
|
||||
GimpImageType new_type = GIMP_GRAY_IMAGE;
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable))
|
||||
new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
|
||||
|
||||
new_tiles = tile_manager_new (gimp_item_get_width (item),
|
||||
gimp_item_get_height (item),
|
||||
GIMP_IMAGE_TYPE_BYTES (new_type));
|
||||
|
||||
gimp_drawable_convert_tiles_grayscale (drawable, new_tiles);
|
||||
|
||||
gimp_drawable_set_tiles (drawable, FALSE, NULL,
|
||||
new_tiles, new_type);
|
||||
tile_manager_unref (new_tiles);
|
||||
gimp_drawable_convert_grayscale (drawable);
|
||||
}
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable))
|
||||
|
|
|
@ -32,6 +32,58 @@
|
|||
#include "gimpimage.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_drawable_convert_rgb (GimpDrawable *drawable)
|
||||
{
|
||||
GimpImageType type;
|
||||
TileManager *tiles;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (! gimp_drawable_is_rgb (drawable));
|
||||
|
||||
type = GIMP_RGB_IMAGE;
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable))
|
||||
type = GIMP_IMAGE_TYPE_WITH_ALPHA (type);
|
||||
|
||||
tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (drawable)),
|
||||
gimp_item_get_height (GIMP_ITEM (drawable)),
|
||||
GIMP_IMAGE_TYPE_BYTES (type));
|
||||
|
||||
gimp_drawable_convert_tiles_rgb (drawable, tiles);
|
||||
|
||||
gimp_drawable_set_tiles (drawable,
|
||||
gimp_item_is_attached (GIMP_ITEM (drawable)), NULL,
|
||||
tiles, type);
|
||||
tile_manager_unref (tiles);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_convert_grayscale (GimpDrawable *drawable)
|
||||
{
|
||||
GimpImageType type;
|
||||
TileManager *tiles;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (! gimp_drawable_is_gray (drawable));
|
||||
|
||||
type = GIMP_GRAY_IMAGE;
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable))
|
||||
type = GIMP_IMAGE_TYPE_WITH_ALPHA (type);
|
||||
|
||||
tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (drawable)),
|
||||
gimp_item_get_height (GIMP_ITEM (drawable)),
|
||||
GIMP_IMAGE_TYPE_BYTES (type));
|
||||
|
||||
gimp_drawable_convert_tiles_grayscale (drawable, tiles);
|
||||
|
||||
gimp_drawable_set_tiles (drawable,
|
||||
gimp_item_is_attached (GIMP_ITEM (drawable)), NULL,
|
||||
tiles, type);
|
||||
tile_manager_unref (tiles);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
|
||||
TileManager *new_tiles)
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#define __GIMP_DRAWABLE_CONVERT_H__
|
||||
|
||||
|
||||
void gimp_drawable_convert_rgb (GimpDrawable *drawable);
|
||||
void gimp_drawable_convert_grayscale (GimpDrawable *drawable);
|
||||
|
||||
void gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
|
||||
TileManager *new_tiles);
|
||||
void gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
|
||||
|
|
|
@ -958,40 +958,44 @@ gimp_image_convert (GimpImage *image,
|
|||
list;
|
||||
list = g_list_next (list), nth_layer++)
|
||||
{
|
||||
GimpLayer *layer = list->data;
|
||||
GimpImageType new_layer_type;
|
||||
TileManager *new_tiles;
|
||||
|
||||
new_layer_type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (new_type);
|
||||
|
||||
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
||||
new_layer_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_layer_type);
|
||||
|
||||
new_tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (layer)),
|
||||
gimp_item_get_height (GIMP_ITEM (layer)),
|
||||
GIMP_IMAGE_TYPE_BYTES (new_layer_type));
|
||||
GimpLayer *layer = list->data;
|
||||
|
||||
switch (new_type)
|
||||
{
|
||||
case GIMP_RGB:
|
||||
gimp_drawable_convert_tiles_rgb (GIMP_DRAWABLE (layer),
|
||||
new_tiles);
|
||||
gimp_drawable_convert_rgb (GIMP_DRAWABLE (layer));
|
||||
break;
|
||||
|
||||
case GIMP_GRAY:
|
||||
gimp_drawable_convert_tiles_grayscale (GIMP_DRAWABLE (layer),
|
||||
new_tiles);
|
||||
gimp_drawable_convert_grayscale (GIMP_DRAWABLE (layer));
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED:
|
||||
quantobj->nth_layer = nth_layer;
|
||||
(* quantobj->second_pass) (quantobj, layer, new_tiles);
|
||||
{
|
||||
GimpImageType new_layer_type;
|
||||
TileManager *new_tiles;
|
||||
|
||||
new_layer_type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (new_type);
|
||||
|
||||
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
||||
new_layer_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_layer_type);
|
||||
|
||||
new_tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (layer)),
|
||||
gimp_item_get_height (GIMP_ITEM (layer)),
|
||||
GIMP_IMAGE_TYPE_BYTES (new_layer_type));
|
||||
|
||||
quantobj->nth_layer = nth_layer;
|
||||
(* quantobj->second_pass) (quantobj, layer, new_tiles);
|
||||
|
||||
gimp_drawable_set_tiles (GIMP_DRAWABLE (layer), TRUE, NULL,
|
||||
new_tiles, new_layer_type);
|
||||
tile_manager_unref (new_tiles);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_drawable_set_tiles (GIMP_DRAWABLE (layer), TRUE, NULL,
|
||||
new_tiles, new_layer_type);
|
||||
tile_manager_unref (new_tiles);
|
||||
}
|
||||
|
||||
switch (new_type)
|
||||
|
|
|
@ -542,32 +542,31 @@ gimp_layer_convert (GimpItem *item,
|
|||
|
||||
if (old_base_type != new_base_type)
|
||||
{
|
||||
TileManager *new_tiles;
|
||||
GimpImageType new_type;
|
||||
|
||||
new_type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (new_base_type);
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable))
|
||||
new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
|
||||
|
||||
new_tiles = tile_manager_new (gimp_item_get_width (item),
|
||||
gimp_item_get_height (item),
|
||||
GIMP_IMAGE_TYPE_BYTES (new_type));
|
||||
|
||||
switch (new_base_type)
|
||||
{
|
||||
case GIMP_RGB:
|
||||
gimp_drawable_convert_tiles_rgb (drawable, new_tiles);
|
||||
gimp_drawable_convert_rgb (drawable);
|
||||
break;
|
||||
|
||||
case GIMP_GRAY:
|
||||
gimp_drawable_convert_tiles_grayscale (drawable, new_tiles);
|
||||
gimp_drawable_convert_grayscale (drawable);
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED:
|
||||
{
|
||||
PixelRegion layerPR;
|
||||
PixelRegion newPR;
|
||||
TileManager *new_tiles;
|
||||
GimpImageType new_type;
|
||||
PixelRegion layerPR;
|
||||
PixelRegion newPR;
|
||||
|
||||
new_type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (new_base_type);
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable))
|
||||
new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
|
||||
|
||||
new_tiles = tile_manager_new (gimp_item_get_width (item),
|
||||
gimp_item_get_height (item),
|
||||
GIMP_IMAGE_TYPE_BYTES (new_type));
|
||||
|
||||
pixel_region_init (&layerPR, gimp_drawable_get_tiles (drawable),
|
||||
0, 0,
|
||||
|
@ -583,13 +582,13 @@ gimp_layer_convert (GimpItem *item,
|
|||
gimp_layer_transform_color (dest_image,
|
||||
&layerPR, gimp_drawable_type (drawable),
|
||||
&newPR, new_type);
|
||||
|
||||
gimp_drawable_set_tiles (drawable, FALSE, NULL,
|
||||
new_tiles, new_type);
|
||||
tile_manager_unref (new_tiles);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_drawable_set_tiles (drawable, FALSE, NULL,
|
||||
new_tiles, new_type);
|
||||
tile_manager_unref (new_tiles);
|
||||
}
|
||||
|
||||
if (layer->mask)
|
||||
|
|
Loading…
Reference in New Issue