Commit 37269769 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added GIMP_IMAGE_TYPE_IS_[RGB|GRAY|INDEXED]() and

2001-12-14  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage.[ch]: added
	GIMP_IMAGE_TYPE_IS_[RGB|GRAY|INDEXED]() and
	GIMP_IMAGE_TYPE_BASE_TYPE() macros.

	* app/plug-in/plug-in.[ch]: new enum PlugInImageType instead of
	multiple #defines.

	* app/gui/file-dialog-utils.[ch]: file_dialog_update_menus(): take
	a GimpImageType instead of the PlugInImageType.

	* app/core/gimpdrawable-preview.c
	* app/core/gimpdrawable-transform.c
	* app/core/gimpdrawable.c
	* app/core/gimpimage-contiguous-region.c
	* app/core/gimpimage-mask.c
	* app/core/gimpimage-merge.c
	* app/core/gimplayermask.c
	* app/core/gimppalette-import.c
	* app/display/gimpdisplay-handlers.c
	* app/display/gimpdisplayshell-render.c
	* app/gui/file-save-dialog.c
	* app/gui/toolbox.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorpickertool.c
	* tools/pdbgen/pdb/convert.pdb
	* tools/pdbgen/pdb/image.pdb: use the new macros, cleanups like
	storing GimpImageType in GimpImageType variables, not just gint.

	* app/pdb/convert_cmds.c
	* app/pdb/image_cmds.c: regenerated.

	* app/widgets/gimpdialogfactory.c: save the state of the "Auto"
	button in sessionrc.
parent 05653ef1
2001-12-14 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.[ch]: added
GIMP_IMAGE_TYPE_IS_[RGB|GRAY|INDEXED]() and
GIMP_IMAGE_TYPE_BASE_TYPE() macros.
* app/plug-in/plug-in.[ch]: new enum PlugInImageType instead of
multiple #defines.
* app/gui/file-dialog-utils.[ch]: file_dialog_update_menus(): take
a GimpImageType instead of the PlugInImageType.
* app/core/gimpdrawable-preview.c
* app/core/gimpdrawable-transform.c
* app/core/gimpdrawable.c
* app/core/gimpimage-contiguous-region.c
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayermask.c
* app/core/gimppalette-import.c
* app/display/gimpdisplay-handlers.c
* app/display/gimpdisplayshell-render.c
* app/gui/file-save-dialog.c
* app/gui/toolbox.c
* app/tools/gimpclonetool.c
* app/tools/gimpcolorpickertool.c
* tools/pdbgen/pdb/convert.pdb
* tools/pdbgen/pdb/image.pdb: use the new macros, cleanups like
storing GimpImageType in GimpImageType variables, not just gint.
* app/pdb/convert_cmds.c
* app/pdb/image_cmds.c: regenerated.
* app/widgets/gimpdialogfactory.c: save the state of the "Auto"
button in sessionrc.
2001-12-13 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-deserialize.h
......
......@@ -3551,11 +3551,11 @@ plug_in_args_destroy (Argument *args,
g_free (args);
}
gint
PlugInImageType
plug_in_image_types_parse (gchar *image_types)
{
gchar *type_spec = image_types;
gint types = 0;
gchar *type_spec = image_types;
PlugInImageType types = 0;
/*
* If the plug_in registers with image_type == NULL or "", return 0
......
......@@ -130,17 +130,17 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* Get the background color */
gimp_image_get_background (gimage, drawable, bg_col);
switch (gimp_drawable_type (drawable))
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
case GIMP_RGB:
bg_col[ALPHA_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_PIX;
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
case GIMP_GRAY:
bg_col[ALPHA_G_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_G_PIX;
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED:
bg_col[ALPHA_I_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_I_PIX;
/* If the gimage is indexed color, ignore smoothing value */
......
......@@ -114,18 +114,16 @@ gimp_drawable_preview_private (GimpDrawable *drawable,
/* The hard way */
else
{
switch (gimp_drawable_type (drawable))
type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
switch (type)
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
type = GIMP_RGB;
bytes = gimp_drawable_bytes (drawable);
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
type = GIMP_GRAY;
case GIMP_RGB:
case GIMP_GRAY:
bytes = gimp_drawable_bytes (drawable);
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
type = GIMP_INDEXED;
case GIMP_INDEXED:
bytes = (gimp_drawable_type (drawable) == GIMP_INDEXED_IMAGE) ? 3 : 4;
break;
}
......
......@@ -130,17 +130,17 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* Get the background color */
gimp_image_get_background (gimage, drawable, bg_col);
switch (gimp_drawable_type (drawable))
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
case GIMP_RGB:
bg_col[ALPHA_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_PIX;
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
case GIMP_GRAY:
bg_col[ALPHA_G_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_G_PIX;
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED:
bg_col[ALPHA_I_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_I_PIX;
/* If the gimage is indexed color, ignore smoothing value */
......
......@@ -584,9 +584,9 @@ gimp_drawable_fill (GimpDrawable *drawable,
g_return_if_fail (gimage != NULL);
switch (gimp_drawable_type (drawable))
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
case GIMP_RGB:
gimp_rgba_get_uchar (color,
&c[RED_PIX],
&c[GREEN_PIX],
......@@ -596,7 +596,7 @@ gimp_drawable_fill (GimpDrawable *drawable,
c[ALPHA_PIX] = 255;
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
case GIMP_GRAY:
gimp_rgba_get_uchar (color,
&c[GRAY_PIX],
NULL,
......@@ -606,7 +606,7 @@ gimp_drawable_fill (GimpDrawable *drawable,
c[ALPHA_G_PIX] = 255;
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED:
gimp_rgb_get_uchar (color,
&c[RED_PIX],
&c[GREEN_PIX],
......@@ -749,30 +749,7 @@ gimp_drawable_type_with_alpha (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
if (gimp_drawable_has_alpha (drawable))
{
return gimp_drawable_type (drawable);
}
else
{
switch (gimp_drawable_type (drawable))
{
case GIMP_RGB_IMAGE:
return GIMP_RGBA_IMAGE;
break;
case GIMP_GRAY_IMAGE:
return GIMP_GRAYA_IMAGE;
break;
case GIMP_INDEXED_IMAGE:
return GIMP_INDEXEDA_IMAGE;
break;
default:
g_assert_not_reached ();
break;
}
}
return -1;
return GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
}
gboolean
......@@ -780,11 +757,7 @@ gimp_drawable_is_rgb (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
if (gimp_drawable_type (drawable) == GIMP_RGBA_IMAGE ||
gimp_drawable_type (drawable) == GIMP_RGB_IMAGE)
return TRUE;
else
return FALSE;
return GIMP_IMAGE_TYPE_IS_RGB (gimp_drawable_type (drawable));
}
gboolean
......@@ -792,11 +765,7 @@ gimp_drawable_is_gray (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
if (gimp_drawable_type (drawable) == GIMP_GRAYA_IMAGE ||
gimp_drawable_type (drawable) == GIMP_GRAY_IMAGE)
return TRUE;
else
return FALSE;
return GIMP_IMAGE_TYPE_IS_GRAY (gimp_drawable_type (drawable));
}
gboolean
......@@ -804,11 +773,7 @@ gimp_drawable_is_indexed (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
if (gimp_drawable_type (drawable) == GIMP_INDEXEDA_IMAGE ||
gimp_drawable_type (drawable) == GIMP_INDEXED_IMAGE)
return TRUE;
else
return FALSE;
return GIMP_IMAGE_TYPE_IS_INDEXED (gimp_drawable_type (drawable));
}
TileManager *
......@@ -844,32 +809,13 @@ gimp_drawable_bytes (const GimpDrawable *drawable)
gint
gimp_drawable_bytes_with_alpha (const GimpDrawable *drawable)
{
GimpImageType type;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
if (gimp_drawable_has_alpha (drawable))
{
return drawable->bytes;
}
else
{
switch (gimp_drawable_type (drawable))
{
case GIMP_RGB_IMAGE:
return 4;
break;
case GIMP_GRAY_IMAGE:
return 2;
break;
case GIMP_INDEXED_IMAGE:
return 2;
break;
default:
g_assert_not_reached ();
break;
}
}
type = GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
return -1;
return GIMP_IMAGE_TYPE_BYTES (type);
}
gint
......
......@@ -90,7 +90,6 @@ gimp_image_contiguous_region_by_seed (GimpImage *gimage,
guchar *start;
gboolean has_alpha;
gboolean indexed;
gint type;
gint bytes;
Tile *tile;
......@@ -101,10 +100,9 @@ gimp_image_contiguous_region_by_seed (GimpImage *gimage,
{
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
gimage->width, gimage->height, FALSE);
type = gimp_image_projection_type (gimage);
has_alpha = (type == GIMP_RGBA_IMAGE ||
type == GIMP_GRAYA_IMAGE ||
type == GIMP_INDEXEDA_IMAGE);
has_alpha =
GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage));
}
else
{
......@@ -113,6 +111,7 @@ gimp_image_contiguous_region_by_seed (GimpImage *gimage,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
FALSE);
has_alpha = gimp_drawable_has_alpha (drawable);
}
indexed = gimp_drawable_is_indexed (drawable);
......@@ -123,10 +122,10 @@ gimp_image_contiguous_region_by_seed (GimpImage *gimage,
bytes = has_alpha ? 4 : 3;
}
mask = gimp_channel_new_mask (gimage, srcPR.w, srcPR.h);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE(mask)),
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0,
gimp_drawable_width (GIMP_DRAWABLE(mask)),
gimp_drawable_height (GIMP_DRAWABLE(mask)),
gimp_drawable_width (GIMP_DRAWABLE (mask)),
gimp_drawable_height (GIMP_DRAWABLE (mask)),
TRUE);
tile = tile_manager_get_tile (srcPR.tiles, x, y, TRUE, FALSE);
......@@ -156,19 +155,19 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
* use the same antialiasing scheme as in fuzzy_select. Modify the gimage's
* mask to reflect the additional selection
*/
GimpChannel *mask;
PixelRegion imagePR, maskPR;
guchar *image_data;
guchar *mask_data;
guchar *idata, *mdata;
guchar rgb[MAX_CHANNELS];
gint has_alpha, indexed;
gint width, height;
gint bytes, color_bytes, alpha;
gint i, j;
gpointer pr;
gint d_type;
guchar col[MAX_CHANNELS];
GimpChannel *mask;
PixelRegion imagePR, maskPR;
guchar *image_data;
guchar *mask_data;
guchar *idata, *mdata;
guchar rgb[MAX_CHANNELS];
gint has_alpha, indexed;
gint width, height;
gint bytes, color_bytes, alpha;
gint i, j;
gpointer pr;
GimpImageType d_type;
guchar col[MAX_CHANNELS];
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
......@@ -179,16 +178,17 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
/* Get the image information */
if (sample_merged)
{
bytes = gimp_image_projection_bytes (gimage);
d_type = gimp_image_projection_type (gimage);
has_alpha = (d_type == GIMP_RGBA_IMAGE ||
d_type == GIMP_GRAYA_IMAGE ||
d_type == GIMP_INDEXEDA_IMAGE);
indexed = d_type == GIMP_INDEXEDA_IMAGE || d_type == GIMP_INDEXED_IMAGE;
width = gimage->width;
height = gimage->height;
bytes = gimp_image_projection_bytes (gimage);
d_type = gimp_image_projection_type (gimage);
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (d_type);
indexed = GIMP_IMAGE_TYPE_IS_INDEXED (d_type);
width = gimage->width;
height = gimage->height;
pixel_region_init (&imagePR, gimp_image_projection (gimage),
0, 0, width, height, FALSE);
0, 0,
width, height,
FALSE);
}
else
{
......@@ -200,7 +200,9 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
height = gimp_drawable_height (drawable);
pixel_region_init (&imagePR, gimp_drawable_data (drawable),
0, 0, width, height, FALSE);
0, 0,
width, height,
FALSE);
}
if (indexed)
......@@ -216,8 +218,11 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
alpha = bytes - 1;
mask = gimp_channel_new_mask (gimage, width, height);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0, width, height, TRUE);
0, 0,
width, height,
TRUE);
/* iterate over the entire image */
for (pr = pixel_regions_register (2, &imagePR, &maskPR);
......
......@@ -197,6 +197,8 @@ gimp_image_mask_translate (GimpImage *gimage,
gint off_x,
gint off_y)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_channel_translate (gimp_image_get_mask (gimage), off_x, off_y);
}
......@@ -208,18 +210,19 @@ gimp_image_mask_extract (GimpImage *gimage,
gboolean keep_indexed,
gboolean add_alpha)
{
TileManager *tiles;
GimpChannel *sel_mask;
PixelRegion srcPR, destPR, maskPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gint x1, y1;
gint x2, y2;
gint off_x, off_y;
gboolean non_empty;
if (!drawable)
return NULL;
TileManager *tiles;
GimpChannel *sel_mask;
PixelRegion srcPR, destPR, maskPR;
guchar bg[MAX_CHANNELS];
GimpImageBaseType base_type = GIMP_RGB;
gint bytes = 0;
gint x1, y1;
gint x2, y2;
gint off_x, off_y;
gboolean non_empty;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (gimage), NULL);
/* If there are no bounds, then just extract the entire image
* This may not be the correct behavior, but after getting rid
......@@ -236,31 +239,33 @@ gimp_image_mask_extract (GimpImage *gimage,
}
/* How many bytes in the temp buffer? */
switch (gimp_drawable_type (drawable))
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
case GIMP_RGB:
bytes = add_alpha ? 4 : drawable->bytes;
type = GIMP_RGB;
base_type = GIMP_RGB;
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
case GIMP_GRAY:
bytes = add_alpha ? 2 : drawable->bytes;
type = GIMP_GRAY;
base_type = GIMP_GRAY;
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED:
if (keep_indexed)
{
bytes = add_alpha ? 2 : drawable->bytes;
type = GIMP_GRAY;
base_type = GIMP_GRAY;
}
else
{
bytes = add_alpha ? 4 : drawable->bytes;
type = GIMP_INDEXED;
base_type = GIMP_INDEXED;
}
break;
default:
bytes = 3;
type = GIMP_RGB;
g_assert_not_reached ();
break;
}
......@@ -292,13 +297,13 @@ gimp_image_mask_extract (GimpImage *gimage,
/* If there is a selection, extract from it */
if (non_empty)
{
pixel_region_init (&maskPR, GIMP_DRAWABLE(sel_mask)->tiles,
pixel_region_init (&maskPR, GIMP_DRAWABLE (sel_mask)->tiles,
(x1 + off_x), (y1 + off_y), (x2 - x1), (y2 - y1),
FALSE);
extract_from_region (&srcPR, &destPR, &maskPR,
gimp_drawable_cmap (drawable),
bg, type,
bg, base_type,
gimp_drawable_has_alpha (drawable), cut_gimage);
if (cut_gimage)
......@@ -319,10 +324,10 @@ gimp_image_mask_extract (GimpImage *gimage,
else
{
/* If the layer is indexed...we need to extract pixels */
if (type == GIMP_INDEXED && !keep_indexed)
if (base_type == GIMP_INDEXED && !keep_indexed)
extract_from_region (&srcPR, &destPR, NULL,
gimp_drawable_cmap (drawable),
bg, type,
bg, base_type,
gimp_drawable_has_alpha (drawable), FALSE);
/* If the layer doesn't have an alpha channel, add one */
else if (bytes > srcPR.bytes)
......
......@@ -305,12 +305,7 @@ gimp_image_merge_layers (GimpImage *gimage,
if (merge_type == FLATTEN_IMAGE ||
gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
{
switch (gimp_image_base_type (gimage))
{
case GIMP_RGB: type = GIMP_RGB_IMAGE; break;
case GIMP_GRAY: type = GIMP_GRAY_IMAGE; break;
case GIMP_INDEXED: type = GIMP_INDEXED_IMAGE; break;
}
type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (gimp_image_base_type (gimage));
merge_layer = gimp_layer_new (gimage, (x2 - x1), (y2 - y1),
type,
......
......@@ -763,33 +763,28 @@ gimp_image_get_new_preview (GimpViewable *viewable,
* Send in all TRUE for visible since that info doesn't matter
* for previews
*/
switch (gimp_drawable_type (GIMP_DRAWABLE (layer)))
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
{
case GIMP_RGB_IMAGE: case GIMP_GRAY_IMAGE: case GIMP_INDEXED_IMAGE:
if (! construct_flag)
initial_region (&src2PR, &src1PR,
mask, NULL, layer->opacity,
layer->mode, visible, INITIAL_INTENSITY);
layer->mode, visible, INITIAL_INTENSITY_ALPHA);
else
combine_regions (&src1PR, &src2PR, &src1PR,
mask, NULL, layer->opacity,
layer->mode, visible, COMBINE_INTEN_A_INTEN);
break;
case GIMP_RGBA_IMAGE: case GIMP_GRAYA_IMAGE: case GIMP_INDEXEDA_IMAGE:
layer->mode, visible, COMBINE_INTEN_A_INTEN_A);
}
else
{
if (! construct_flag)
initial_region (&src2PR, &src1PR,
mask, NULL, layer->opacity,
layer->mode, visible, INITIAL_INTENSITY_ALPHA);
layer->mode, visible, INITIAL_INTENSITY);
else
combine_regions (&src1PR, &src2PR, &src1PR,
mask, NULL, layer->opacity,
layer->mode, visible, COMBINE_INTEN_A_INTEN_A);
break;
default:
break;
}
layer->mode, visible, COMBINE_INTEN_A_INTEN);
}
construct_flag = TRUE;
}
......
......@@ -25,9 +25,17 @@
#define COLORMAP_SIZE 768
#define GIMP_IMAGE_TYPE_IS_RGB(t) ((t) == GIMP_RGB_IMAGE || \
(t) == GIMP_RGBA_IMAGE)
#define GIMP_IMAGE_TYPE_IS_GRAY(t) ((t) == GIMP_GRAY_IMAGE || \
(t) == GIMP_GRAYA_IMAGE)
#define GIMP_IMAGE_TYPE_IS_INDEXED(t) ((t) == GIMP_INDEXED_IMAGE || \
(t) == GIMP_INDEXEDA_IMAGE)
#define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t) == GIMP_RGBA_IMAGE || \
(t) == GIMP_GRAYA_IMAGE || \
(t) == GIMP_INDEXEDA_IMAGE)
#define GIMP_IMAGE_TYPE_WITH_ALPHA(t) (((t) == GIMP_RGB_IMAGE || \
(t) == GIMP_RGBA_IMAGE) ? \
GIMP_RGBA_IMAGE : \
......@@ -43,6 +51,15 @@
(t) == GIMP_GRAY_IMAGE ? 1 : \
(t) == GIMP_INDEXEDA_IMAGE ? 2 : \
(t) == GIMP_INDEXED_IMAGE ? 1 : -1)
#define GIMP_IMAGE_TYPE_BASE_TYPE(t) (((t) == GIMP_RGB_IMAGE || \
(t) == GIMP_RGBA_IMAGE) ? \
GIMP_RGB : \
((t) == GIMP_GRAY_IMAGE || \
(t) == GIMP_GRAYA_IMAGE) ? \
GIMP_GRAY : \
((t) == GIMP_INDEXED_IMAGE || \
(t) == GIMP_INDEXEDA_IMAGE) ? \
GIMP_INDEXED : -1)
#define GIMP_IMAGE_TYPE_FROM_BASE_TYPE(b) ((b) == GIMP_RGB ? \
GIMP_RGB_IMAGE : \
......
......@@ -27,6 +27,7 @@
#include "core-types.h"
#include "gimplayer.h"
#include "gimplayermask.h"
#include "gimpmarshal.h"
......@@ -45,7 +46,7 @@ enum
static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layermask);
static void gimp_layer_mask_init (GimpLayerMask *layer_mask);
static guint layer_mask_signals[LAST_SIGNAL] = { 0 };
......@@ -169,16 +170,21 @@ gimp_layer_mask_copy (const GimpLayerMask *layer_mask)
}
void
gimp_layer_mask_set_layer (GimpLayerMask *mask,
gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer)
{
mask->layer = layer;
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
g_return_if_fail (! layer || GIMP_IS_LAYER (layer));
layer_mask->layer = layer;
}
GimpLayer *
gimp_layer_mask_get_layer (const GimpLayerMask *mask)
gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask)
{
return mask->layer;
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), NULL);
return layer_mask->layer;
}
void
......@@ -189,7 +195,7 @@ gimp_layer_mask_set_apply (GimpLayerMask *layer_mask,
if (layer_mask->apply_mask != apply)
{
layer_mask->apply_mask = apply;
layer_mask->apply_mask = apply ? TRUE : FALSE;
if (layer_mask->layer)
{
......@@ -224,7 +230,7 @@ gimp_layer_mask_set_edit (GimpLayerMask *layer_mask,
if (layer_mask->edit_mask != edit)
{
layer_mask->edit_mask = edit;
layer_mask->edit_mask = edit ? TRUE : FALSE;
g_signal_emit (G_OBJECT (layer_mask),
layer_mask_signals[EDIT_CHANGED], 0);
......@@ -247,7 +253,7 @@ gimp_layer_mask_set_show (GimpLayerMask *layer_mask,
if (layer_mask->show_mask != show)
{
layer_mask->show_mask = show;
layer_mask->show_mask = show ? TRUE : FALSE;
if (layer_mask->layer)
{
......
......@@ -259,18 +259,18 @@ gimp_palette_import_from_image (GimpImage *gimage,
gint n_colors,
gint threshold)
{
PixelRegion imagePR;
guchar *image_data;
guchar *idata;
guchar rgb[MAX_CHANNELS];
guchar rgb_real[MAX_CHANNELS];
gint has_alpha, indexed;
gint width, height;
gint bytes, alpha;
gint i, j;
void *pr;
gint d_type;
GHashTable *store_array = NULL;
PixelRegion imagePR;
guchar *image_data;
guchar *idata;
guchar rgb[MAX_CHANNELS];
guchar rgb_real[MAX_CHANNELS];
gboolean has_alpha, indexed;
gint width, height;
gint bytes, alpha;
gint i, j;
void *pr;
GimpImageType d_type;
GHashTable *store_array = NULL;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (palette_name != NULL, NULL);
......@@ -278,10 +278,10 @@ gimp_palette_import_from_image (GimpImage *gimage,
g_return_val_if_fail (threshold > 0, NULL);
/* Get the image information */
bytes = gimp_image_projection_bytes (gimage);
d_type = gimp_image_projection_type (gimage);
bytes = gimp_image_projection_bytes (gimage);
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (d_type);
indexed = d_type == GIMP_INDEXEDA_IMAGE || d_type == GIMP_INDEXED_IMAGE;
indexed = GIMP_IMAGE_TYPE_IS_INDEXED (d_type);
width = gimage->width;
height = gimage->height;
......@@ -341,9 +341,6 @@ gimp_palette_import_from_indexed_image (GimpImage *gimage,
g_return_val_if_fail (gimp_image_base_type (gimage) == GIMP_INDEXED, NULL);
g_return_val_if_fail (palette_name != NULL, NULL);
if (! (gimage && gimp_image_base_type (gimage) == GIMP_INDEXED))
return NULL;
palette = GIMP_PALETTE (gimp_palette_new (palette_name));
for (count= 0; count < gimage->num_cols; ++count)
......
......@@ -91,20 +91,45 @@ file_dialog_update_name (PlugInProcDef *proc,
}