Remove "old_base_type" parameters from gimp_drawable_convert_tiles_foo()

I have no idea how ancient these parameters were, but the drawable
knows about its type itself, so no need to pass it in.
This commit is contained in:
Michael Natterer 2009-09-08 17:49:48 +02:00
parent 1ecf6b5bc8
commit f3bae9ac57
5 changed files with 27 additions and 37 deletions

View File

@ -430,13 +430,10 @@ static void
gimp_channel_convert (GimpItem *item,
GimpImage *dest_image)
{
GimpChannel *channel = GIMP_CHANNEL (item);
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpImageBaseType old_base_type;
GimpChannel *channel = GIMP_CHANNEL (item);
GimpDrawable *drawable = GIMP_DRAWABLE (item);
old_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
if (old_base_type != GIMP_GRAY)
if (! gimp_drawable_is_gray (drawable))
{
TileManager *new_tiles;
GimpImageType new_type = GIMP_GRAY_IMAGE;
@ -448,7 +445,7 @@ gimp_channel_convert (GimpItem *item,
gimp_item_get_height (item),
GIMP_IMAGE_TYPE_BYTES (new_type));
gimp_drawable_convert_tiles_grayscale (drawable, new_tiles, old_base_type);
gimp_drawable_convert_tiles_grayscale (drawable, new_tiles);
gimp_drawable_set_tiles (drawable, FALSE, NULL,
new_tiles, new_type);

View File

@ -29,16 +29,17 @@
#include "gimpdrawable.h"
#include "gimpdrawable-convert.h"
#include "gimpimage.h"
void
gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
TileManager *new_tiles,
GimpImageBaseType old_base_type)
gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
TileManager *new_tiles)
{
PixelRegion srcPR, destPR;
gint row, col;
gint offset;
GimpImageType type;
gint has_alpha;
const guchar *src, *s;
guchar *dest, *d;
@ -48,6 +49,7 @@ gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (new_tiles != NULL);
type = gimp_drawable_type (drawable);
has_alpha = gimp_drawable_has_alpha (drawable);
g_return_if_fail (tile_manager_bpp (new_tiles) == (has_alpha ? 4 : 3));
@ -65,8 +67,7 @@ gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
gimp_item_get_height (GIMP_ITEM (drawable)),
TRUE);
switch (old_base_type)
switch (GIMP_IMAGE_TYPE_BASE_TYPE (type))
{
case GIMP_GRAY:
for (pr = pixel_regions_register (2, &srcPR, &destPR);
@ -136,13 +137,13 @@ gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
}
void
gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
TileManager *new_tiles,
GimpImageBaseType old_base_type)
gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
TileManager *new_tiles)
{
PixelRegion srcPR, destPR;
gint row, col;
gint offset, val;
GimpImageType type;
gboolean has_alpha;
const guchar *src, *s;
guchar *dest, *d;
@ -152,6 +153,7 @@ gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (new_tiles != NULL);
type = gimp_drawable_type (drawable);
has_alpha = gimp_drawable_has_alpha (drawable);
g_return_if_fail (tile_manager_bpp (new_tiles) == (has_alpha ? 2 : 1));
@ -169,7 +171,7 @@ gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
gimp_item_get_height (GIMP_ITEM (drawable)),
TRUE);
switch (old_base_type)
switch (GIMP_IMAGE_TYPE_BASE_TYPE (type))
{
case GIMP_RGB:
for (pr = pixel_regions_register (2, &srcPR, &destPR);

View File

@ -19,12 +19,10 @@
#define __GIMP_DRAWABLE_CONVERT_H__
void gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
TileManager *new_tiles,
GimpImageBaseType old_base_type);
void gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
TileManager *new_tiles,
GimpImageBaseType old_base_type);
void gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
TileManager *new_tiles);
void gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
TileManager *new_tiles);
#endif /* __GIMP_DRAWABLE_CONVERT_H__ */

View File

@ -975,11 +975,11 @@ gimp_image_convert (GimpImage *image,
{
case GIMP_RGB:
gimp_drawable_convert_tiles_rgb (GIMP_DRAWABLE (layer),
new_tiles, old_type);
new_tiles);
break;
case GIMP_GRAY:
gimp_drawable_convert_tiles_grayscale (GIMP_DRAWABLE (layer),
new_tiles, old_type);
new_tiles);
break;
case GIMP_INDEXED:
quantobj->nth_layer = nth_layer;

View File

@ -557,15 +557,11 @@ gimp_layer_convert (GimpItem *item,
switch (new_base_type)
{
case GIMP_RGB:
gimp_drawable_convert_tiles_rgb (drawable,
new_tiles,
old_base_type);
gimp_drawable_convert_tiles_rgb (drawable, new_tiles);
break;
case GIMP_GRAY:
gimp_drawable_convert_tiles_grayscale (drawable,
new_tiles,
old_base_type);
gimp_drawable_convert_tiles_grayscale (drawable, new_tiles);
break;
case GIMP_INDEXED:
@ -1529,23 +1525,20 @@ gimp_layer_create_mask (const GimpLayer *layer,
case GIMP_ADD_COPY_MASK:
{
TileManager *copy_tiles = NULL;
GimpImageType layer_type = gimp_drawable_type (drawable);
TileManager *copy_tiles = NULL;
if (GIMP_IMAGE_TYPE_BASE_TYPE (layer_type) != GIMP_GRAY)
if (! gimp_drawable_is_gray (drawable))
{
GimpImageType copy_type;
copy_type = (GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type) ?
copy_type = (gimp_drawable_has_alpha (drawable) ?
GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE);
copy_tiles = tile_manager_new (gimp_item_get_width (item),
gimp_item_get_height (item),
GIMP_IMAGE_TYPE_BYTES (copy_type));
gimp_drawable_convert_tiles_grayscale (drawable,
copy_tiles,
GIMP_IMAGE_TYPE_BASE_TYPE (layer_type));
gimp_drawable_convert_tiles_grayscale (drawable, copy_tiles);
pixel_region_init (&srcPR, copy_tiles,
0, 0,