mirror of https://github.com/GNOME/gimp.git
removed function map_to_color() since it does not belong here and the two
2003-09-05 Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs.[ch]: removed function map_to_color() since it does not belong here and the two places using it look much cleaner when doing that stuff themselves. * app/core/gimpdrawable-preview.c: cleanup. (gimp_drawable_preview_scale): do the indexed palette lookup here instead of calling map_to_color(). * app/core/gimpimage.c (gimp_image_get_color): transform the colors here instead of calling map_to_color(). * app/core/gimpimage.[ch] (gimp_image_get_color): reordered parameters src parameters are before dest parameters. Made the src color const. (gimp_image_transform_color): reordered so src parameters are *after* dest parameters (since this function operates on the dest image and it makes sense to have the dest parameters together). Made the src color const here, too. * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable.c * app/core/gimpimage-contiguous-region.c * app/core/gimpimage-projection.c * app/core/gimpimagemap.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/paint/gimpclone.c * app/paint/gimppaintcore.c: changed accordingly. * app/core/gimpedit.c (gimp_edit_cut,copy): simplified by moving the "cropped" variable to a local scope. * app/core/gimpimage-mask.c: calling gimp_image_update() followed by gimp_viewable_imvalidate_preview(drawable) is equal to calling gimp_drawable_update() directly.
This commit is contained in:
parent
3a3a57014b
commit
aaf84a73d2
39
ChangeLog
39
ChangeLog
|
@ -1,3 +1,42 @@
|
|||
2003-09-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/paint-funcs/paint-funcs.[ch]: removed function map_to_color()
|
||||
since it does not belong here and the two places using it look much
|
||||
cleaner when doing that stuff themselves.
|
||||
|
||||
* app/core/gimpdrawable-preview.c: cleanup.
|
||||
(gimp_drawable_preview_scale): do the indexed palette lookup here
|
||||
instead of calling map_to_color().
|
||||
|
||||
* app/core/gimpimage.c (gimp_image_get_color): transform the
|
||||
colors here instead of calling map_to_color().
|
||||
|
||||
* app/core/gimpimage.[ch] (gimp_image_get_color): reordered
|
||||
parameters src parameters are before dest parameters.
|
||||
Made the src color const.
|
||||
|
||||
(gimp_image_transform_color): reordered so src parameters are
|
||||
*after* dest parameters (since this function operates on the dest
|
||||
image and it makes sense to have the dest parameters
|
||||
together). Made the src color const here, too.
|
||||
|
||||
* app/core/gimpdrawable-bucket-fill.c
|
||||
* app/core/gimpdrawable.c
|
||||
* app/core/gimpimage-contiguous-region.c
|
||||
* app/core/gimpimage-projection.c
|
||||
* app/core/gimpimagemap.c
|
||||
* app/core/gimplayer.c
|
||||
* app/core/gimppalette-import.c
|
||||
* app/paint/gimpclone.c
|
||||
* app/paint/gimppaintcore.c: changed accordingly.
|
||||
|
||||
* app/core/gimpedit.c (gimp_edit_cut,copy): simplified by
|
||||
moving the "cropped" variable to a local scope.
|
||||
|
||||
* app/core/gimpimage-mask.c: calling gimp_image_update() followed
|
||||
by gimp_viewable_imvalidate_preview(drawable) is equal to calling
|
||||
gimp_drawable_update() directly.
|
||||
|
||||
2003-09-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimppreviewcache.[ch]: code cleanup. Removed the
|
||||
|
|
|
@ -49,8 +49,7 @@ const GimpBuffer *
|
|||
gimp_edit_cut (GimpImage *gimage,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
TileManager *cut;
|
||||
TileManager *cropped_cut;
|
||||
TileManager *tiles;
|
||||
gboolean empty;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
@ -64,38 +63,36 @@ gimp_edit_cut (GimpImage *gimage,
|
|||
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
|
||||
|
||||
/* Next, cut the mask portion from the gimage */
|
||||
cut = gimp_image_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
|
||||
tiles = gimp_image_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
|
||||
|
||||
if (cut)
|
||||
if (tiles)
|
||||
gimage->gimp->have_current_cut_buffer = TRUE;
|
||||
|
||||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (cut && ! empty)
|
||||
if (tiles && ! empty)
|
||||
{
|
||||
cropped_cut = tile_manager_crop (cut, 0);
|
||||
TileManager *crop;
|
||||
|
||||
if (cropped_cut != cut)
|
||||
crop = tile_manager_crop (tiles, 0);
|
||||
|
||||
if (crop != tiles)
|
||||
{
|
||||
tile_manager_unref (cut);
|
||||
cut = NULL;
|
||||
tile_manager_unref (tiles);
|
||||
tiles = crop;
|
||||
}
|
||||
}
|
||||
else if (cut)
|
||||
cropped_cut = cut;
|
||||
else
|
||||
cropped_cut = NULL;
|
||||
|
||||
/* end the group undo */
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
if (cropped_cut)
|
||||
if (tiles)
|
||||
{
|
||||
/* Free the old global edit buffer */
|
||||
if (gimage->gimp->global_buffer)
|
||||
g_object_unref (gimage->gimp->global_buffer);
|
||||
|
||||
/* Set the global edit buffer */
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (cropped_cut,
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
|
||||
"Global Buffer",
|
||||
FALSE);
|
||||
|
||||
|
@ -109,8 +106,7 @@ const GimpBuffer *
|
|||
gimp_edit_copy (GimpImage *gimage,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
TileManager *copy;
|
||||
TileManager *cropped_copy;
|
||||
TileManager *tiles;
|
||||
gboolean empty;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
@ -124,38 +120,36 @@ gimp_edit_copy (GimpImage *gimage,
|
|||
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
|
||||
|
||||
/* First, copy the masked portion of the gimage */
|
||||
copy = gimp_image_mask_extract (gimage, drawable, FALSE, FALSE, TRUE);
|
||||
tiles = gimp_image_mask_extract (gimage, drawable, FALSE, FALSE, TRUE);
|
||||
|
||||
if (copy)
|
||||
if (tiles)
|
||||
gimage->gimp->have_current_cut_buffer = TRUE;
|
||||
|
||||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (copy && ! empty)
|
||||
if (tiles && ! empty)
|
||||
{
|
||||
cropped_copy = tile_manager_crop (copy, 0);
|
||||
TileManager *crop;
|
||||
|
||||
if (cropped_copy != copy)
|
||||
crop = tile_manager_crop (tiles, 0);
|
||||
|
||||
if (crop != tiles)
|
||||
{
|
||||
tile_manager_unref (copy);
|
||||
copy = NULL;
|
||||
tile_manager_unref (tiles);
|
||||
tiles = crop;
|
||||
}
|
||||
}
|
||||
else if (copy)
|
||||
cropped_copy = copy;
|
||||
else
|
||||
cropped_copy = NULL;
|
||||
|
||||
/* end the group undo */
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
if (cropped_copy)
|
||||
if (tiles)
|
||||
{
|
||||
/* Free the old global edit buffer */
|
||||
if (gimage->gimp->global_buffer)
|
||||
g_object_unref (gimage->gimp->global_buffer);
|
||||
|
||||
/* Set the global edit buffer */
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (cropped_copy,
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
|
||||
"Global Buffer",
|
||||
FALSE);
|
||||
|
||||
|
@ -253,8 +247,8 @@ gimp_edit_paste_as_new (Gimp *gimp,
|
|||
|
||||
/* create a new image (always of type GIMP_RGB) */
|
||||
gimage = gimp_create_image (gimp,
|
||||
gimp_buffer_get_width (paste),
|
||||
gimp_buffer_get_height (paste),
|
||||
gimp_buffer_get_width (paste),
|
||||
gimp_buffer_get_height (paste),
|
||||
GIMP_RGB,
|
||||
TRUE);
|
||||
gimp_image_undo_disable (gimage);
|
||||
|
@ -349,6 +343,8 @@ gimp_edit_fill (GimpImage *gimage,
|
|||
if (gimp_drawable_has_alpha (drawable))
|
||||
col [gimp_drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
|
||||
|
||||
g_print ("fill_type: %d\n", fill_type);
|
||||
|
||||
switch (fill_type)
|
||||
{
|
||||
case GIMP_FOREGROUND_FILL:
|
||||
|
|
|
@ -174,7 +174,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
|
|||
|
||||
gimp_rgb_get_uchar (color, &tmp_col[0], &tmp_col[1], &tmp_col[2]);
|
||||
|
||||
gimp_image_transform_color (gimage, drawable, tmp_col, col, GIMP_RGB);
|
||||
gimp_image_transform_color (gimage, drawable, col, GIMP_RGB, tmp_col);
|
||||
}
|
||||
else if (fill_mode == GIMP_PATTERN_BUCKET_FILL)
|
||||
{
|
||||
|
@ -212,10 +212,10 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
|
|||
out_bytes = pat_buf->bytes;
|
||||
while (size--)
|
||||
{
|
||||
gimp_image_transform_color (gimage, drawable, d1, d2,
|
||||
gimp_image_transform_color (gimage, drawable, d2,
|
||||
(in_bytes == 3 ||
|
||||
in_bytes == 4) ?
|
||||
GIMP_RGB : GIMP_GRAY);
|
||||
GIMP_RGB : GIMP_GRAY, d1);
|
||||
/* Handle alpha */
|
||||
if (in_bytes == 4 ||
|
||||
in_bytes == 2 )
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "gimp.h"
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-colormap.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-preview.h"
|
||||
#include "gimplayer.h"
|
||||
|
@ -202,32 +203,33 @@ gimp_drawable_preview_private (GimpDrawable *drawable,
|
|||
gint width,
|
||||
gint height)
|
||||
{
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
GimpImageBaseType type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
TempBuf *ret_buf;
|
||||
TempBuf *ret_buf;
|
||||
|
||||
type = GIMP_RGB;
|
||||
bytes = 0;
|
||||
|
||||
/* The easy way */
|
||||
if (drawable->preview_valid &&
|
||||
(ret_buf = gimp_preview_cache_get (&drawable->preview_cache,
|
||||
width, height)))
|
||||
{
|
||||
/* The easy way */
|
||||
|
||||
return ret_buf;
|
||||
}
|
||||
/* The hard way */
|
||||
else
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (drawable);
|
||||
/* The hard way */
|
||||
|
||||
type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
|
||||
GimpItem *item;
|
||||
TempBuf *preview_buf;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
GimpImageBaseType base_type;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
|
||||
switch (type)
|
||||
item = GIMP_ITEM (drawable);
|
||||
|
||||
base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
|
||||
|
||||
switch (base_type)
|
||||
{
|
||||
case GIMP_RGB:
|
||||
case GIMP_GRAY:
|
||||
|
@ -235,7 +237,7 @@ gimp_drawable_preview_private (GimpDrawable *drawable,
|
|||
break;
|
||||
|
||||
case GIMP_INDEXED:
|
||||
bytes = (gimp_drawable_type (drawable) == GIMP_INDEXED_IMAGE) ? 3 : 4;
|
||||
bytes = gimp_drawable_has_alpha (drawable) ? 4 : 3;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -251,10 +253,10 @@ gimp_drawable_preview_private (GimpDrawable *drawable,
|
|||
subsample += 1;
|
||||
|
||||
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
||||
0, 0,
|
||||
gimp_item_width (item),
|
||||
gimp_item_height (item),
|
||||
FALSE);
|
||||
0, 0,
|
||||
gimp_item_width (item),
|
||||
gimp_item_height (item),
|
||||
FALSE);
|
||||
|
||||
preview_buf = temp_buf_new (width, height, bytes, 0, 0, NULL);
|
||||
|
||||
|
@ -268,11 +270,10 @@ gimp_drawable_preview_private (GimpDrawable *drawable,
|
|||
|
||||
if (GIMP_IS_LAYER (drawable))
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
gimp_drawable_preview_scale (type, gimage->cmap,
|
||||
gimp_drawable_preview_scale (base_type,
|
||||
gimp_image_get_colormap (gimage),
|
||||
&srcPR, &destPR,
|
||||
subsample);
|
||||
}
|
||||
|
@ -315,7 +316,6 @@ gimp_drawable_preview_scale (GimpImageBaseType type,
|
|||
gint i, j;
|
||||
gint frac;
|
||||
gboolean advance_dest;
|
||||
guchar rgb[MAX_CHANNELS];
|
||||
|
||||
orig_width = srcPR->w / subsample;
|
||||
orig_height = srcPR->h / subsample;
|
||||
|
@ -405,11 +405,11 @@ gimp_drawable_preview_scale (GimpImageBaseType type,
|
|||
/* If indexed, transform the color to RGB */
|
||||
if (type == GIMP_INDEXED)
|
||||
{
|
||||
map_to_color (2, cmap, s, rgb);
|
||||
gint index = *s * 3;
|
||||
|
||||
r[RED_PIX] += rgb[RED_PIX] * tot_frac;
|
||||
r[GREEN_PIX] += rgb[GREEN_PIX] * tot_frac;
|
||||
r[BLUE_PIX] += rgb[BLUE_PIX] * tot_frac;
|
||||
r[RED_PIX] += cmap[index++] * tot_frac;
|
||||
r[GREEN_PIX] += cmap[index++] * tot_frac;
|
||||
r[BLUE_PIX] += cmap[index++] * tot_frac;
|
||||
|
||||
if (bytes == 4)
|
||||
r[ALPHA_PIX] += s[ALPHA_I_PIX] * tot_frac;
|
||||
|
|
|
@ -717,7 +717,7 @@ gimp_drawable_fill (GimpDrawable *drawable,
|
|||
&c[RED_PIX],
|
||||
&c[GREEN_PIX],
|
||||
&c[BLUE_PIX]);
|
||||
gimp_image_transform_color (gimage, drawable, c, &i, GIMP_RGB);
|
||||
gimp_image_transform_color (gimage, drawable, &i, GIMP_RGB, c);
|
||||
c[INDEXED_PIX] = i;
|
||||
if (gimp_drawable_type (drawable) == GIMP_INDEXEDA_IMAGE)
|
||||
gimp_rgba_get_uchar (color,
|
||||
|
@ -1015,7 +1015,7 @@ gimp_drawable_get_color_at (GimpDrawable *drawable,
|
|||
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
||||
|
||||
gimp_image_get_color (gimp_item_get_image (GIMP_ITEM (drawable)),
|
||||
gimp_drawable_type (drawable), dest, src);
|
||||
gimp_drawable_type (drawable), src, dest);
|
||||
|
||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (drawable)))
|
||||
dest[3] = src[gimp_drawable_bytes (drawable) - 1];
|
||||
|
|
|
@ -49,8 +49,7 @@ const GimpBuffer *
|
|||
gimp_edit_cut (GimpImage *gimage,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
TileManager *cut;
|
||||
TileManager *cropped_cut;
|
||||
TileManager *tiles;
|
||||
gboolean empty;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
@ -64,38 +63,36 @@ gimp_edit_cut (GimpImage *gimage,
|
|||
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
|
||||
|
||||
/* Next, cut the mask portion from the gimage */
|
||||
cut = gimp_image_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
|
||||
tiles = gimp_image_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
|
||||
|
||||
if (cut)
|
||||
if (tiles)
|
||||
gimage->gimp->have_current_cut_buffer = TRUE;
|
||||
|
||||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (cut && ! empty)
|
||||
if (tiles && ! empty)
|
||||
{
|
||||
cropped_cut = tile_manager_crop (cut, 0);
|
||||
TileManager *crop;
|
||||
|
||||
if (cropped_cut != cut)
|
||||
crop = tile_manager_crop (tiles, 0);
|
||||
|
||||
if (crop != tiles)
|
||||
{
|
||||
tile_manager_unref (cut);
|
||||
cut = NULL;
|
||||
tile_manager_unref (tiles);
|
||||
tiles = crop;
|
||||
}
|
||||
}
|
||||
else if (cut)
|
||||
cropped_cut = cut;
|
||||
else
|
||||
cropped_cut = NULL;
|
||||
|
||||
/* end the group undo */
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
if (cropped_cut)
|
||||
if (tiles)
|
||||
{
|
||||
/* Free the old global edit buffer */
|
||||
if (gimage->gimp->global_buffer)
|
||||
g_object_unref (gimage->gimp->global_buffer);
|
||||
|
||||
/* Set the global edit buffer */
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (cropped_cut,
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
|
||||
"Global Buffer",
|
||||
FALSE);
|
||||
|
||||
|
@ -109,8 +106,7 @@ const GimpBuffer *
|
|||
gimp_edit_copy (GimpImage *gimage,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
TileManager *copy;
|
||||
TileManager *cropped_copy;
|
||||
TileManager *tiles;
|
||||
gboolean empty;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
@ -124,38 +120,36 @@ gimp_edit_copy (GimpImage *gimage,
|
|||
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
|
||||
|
||||
/* First, copy the masked portion of the gimage */
|
||||
copy = gimp_image_mask_extract (gimage, drawable, FALSE, FALSE, TRUE);
|
||||
tiles = gimp_image_mask_extract (gimage, drawable, FALSE, FALSE, TRUE);
|
||||
|
||||
if (copy)
|
||||
if (tiles)
|
||||
gimage->gimp->have_current_cut_buffer = TRUE;
|
||||
|
||||
/* Only crop if the gimage mask wasn't empty */
|
||||
if (copy && ! empty)
|
||||
if (tiles && ! empty)
|
||||
{
|
||||
cropped_copy = tile_manager_crop (copy, 0);
|
||||
TileManager *crop;
|
||||
|
||||
if (cropped_copy != copy)
|
||||
crop = tile_manager_crop (tiles, 0);
|
||||
|
||||
if (crop != tiles)
|
||||
{
|
||||
tile_manager_unref (copy);
|
||||
copy = NULL;
|
||||
tile_manager_unref (tiles);
|
||||
tiles = crop;
|
||||
}
|
||||
}
|
||||
else if (copy)
|
||||
cropped_copy = copy;
|
||||
else
|
||||
cropped_copy = NULL;
|
||||
|
||||
/* end the group undo */
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
if (cropped_copy)
|
||||
if (tiles)
|
||||
{
|
||||
/* Free the old global edit buffer */
|
||||
if (gimage->gimp->global_buffer)
|
||||
g_object_unref (gimage->gimp->global_buffer);
|
||||
|
||||
/* Set the global edit buffer */
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (cropped_copy,
|
||||
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
|
||||
"Global Buffer",
|
||||
FALSE);
|
||||
|
||||
|
@ -253,8 +247,8 @@ gimp_edit_paste_as_new (Gimp *gimp,
|
|||
|
||||
/* create a new image (always of type GIMP_RGB) */
|
||||
gimage = gimp_create_image (gimp,
|
||||
gimp_buffer_get_width (paste),
|
||||
gimp_buffer_get_height (paste),
|
||||
gimp_buffer_get_width (paste),
|
||||
gimp_buffer_get_height (paste),
|
||||
GIMP_RGB,
|
||||
TRUE);
|
||||
gimp_image_undo_disable (gimage);
|
||||
|
@ -349,6 +343,8 @@ gimp_edit_fill (GimpImage *gimage,
|
|||
if (gimp_drawable_has_alpha (drawable))
|
||||
col [gimp_drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
|
||||
|
||||
g_print ("fill_type: %d\n", fill_type);
|
||||
|
||||
switch (fill_type)
|
||||
{
|
||||
case GIMP_FOREGROUND_FILL:
|
||||
|
|
|
@ -276,7 +276,7 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
|
|||
for (j = 0; j < imagePR.w; j++)
|
||||
{
|
||||
/* Get the rgb values for the color */
|
||||
gimp_image_get_color (gimage, d_type, rgb, idata);
|
||||
gimp_image_get_color (gimage, d_type, idata, rgb);
|
||||
|
||||
/* Plug the alpha channel in there */
|
||||
if (has_alpha)
|
||||
|
|
|
@ -158,12 +158,7 @@ gimp_image_mask_extract (GimpImage *gimage,
|
|||
gimp_channel_clear (sel_mask, NULL, TRUE);
|
||||
|
||||
/* Update the region */
|
||||
gimp_image_update (gimage,
|
||||
x1 + off_x, y1 + off_y,
|
||||
(x2 - x1), (y2 - y1));
|
||||
|
||||
/* Invalidate the preview */
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (drawable));
|
||||
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
}
|
||||
else /* Otherwise, get the entire active layer */
|
||||
|
|
|
@ -193,7 +193,7 @@ gimp_image_projection_get_color_at (GimpImage *gimage,
|
|||
tile = tile_manager_get_tile (gimp_image_projection (gimage), x, y,
|
||||
TRUE, FALSE);
|
||||
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
||||
gimp_image_get_color (gimage, gimp_image_projection_type (gimage), dest, src);
|
||||
gimp_image_get_color (gimage, gimp_image_projection_type (gimage), src, dest);
|
||||
|
||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
||||
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
||||
|
|
|
@ -1501,7 +1501,7 @@ gimp_image_get_foreground (const GimpImage *gimage,
|
|||
|
||||
gimp_rgb_get_uchar (&color, &pfg[0], &pfg[1], &pfg[2]);
|
||||
|
||||
gimp_image_transform_color (gimage, drawable, pfg, fg, GIMP_RGB);
|
||||
gimp_image_transform_color (gimage, drawable, fg, GIMP_RGB, pfg);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1520,50 +1520,65 @@ gimp_image_get_background (const GimpImage *gimage,
|
|||
|
||||
gimp_rgb_get_uchar (&color, &pbg[0], &pbg[1], &pbg[2]);
|
||||
|
||||
gimp_image_transform_color (gimage, drawable, pbg, bg, GIMP_RGB);
|
||||
gimp_image_transform_color (gimage, drawable, bg, GIMP_RGB, pbg);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_get_color (const GimpImage *gimage,
|
||||
GimpImageType d_type,
|
||||
guchar *rgb,
|
||||
guchar *src)
|
||||
gimp_image_get_color (const GimpImage *src_gimage,
|
||||
GimpImageType src_type,
|
||||
const guchar *src,
|
||||
guchar *rgb)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (src_gimage));
|
||||
|
||||
switch (d_type)
|
||||
switch (src_type)
|
||||
{
|
||||
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
|
||||
map_to_color (0, NULL, src, rgb);
|
||||
/* Straight copy */
|
||||
*rgb++ = *src++;
|
||||
*rgb++ = *src++;
|
||||
*rgb = *src;
|
||||
break;
|
||||
|
||||
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
|
||||
map_to_color (1, NULL, src, rgb);
|
||||
/* Gray to RG&B */
|
||||
*rgb++ = *src;
|
||||
*rgb++ = *src;
|
||||
*rgb = *src;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
|
||||
map_to_color (2, gimage->cmap, src, rgb);
|
||||
/* Indexed palette lookup */
|
||||
{
|
||||
gint index = *src * 3;
|
||||
|
||||
*rgb++ = src_gimage->cmap[index++];
|
||||
*rgb++ = src_gimage->cmap[index++];
|
||||
*rgb = src_gimage->cmap[index++];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_transform_color (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *src,
|
||||
gimp_image_transform_color (const GimpImage *dest_gimage,
|
||||
const GimpDrawable *dest_drawable,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type)
|
||||
GimpImageBaseType src_type,
|
||||
const guchar *src)
|
||||
{
|
||||
GimpImageType drawable_type;
|
||||
GimpImageType dest_type;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (dest_gimage));
|
||||
|
||||
drawable_type = (drawable ?
|
||||
gimp_drawable_type (drawable) :
|
||||
gimp_image_base_type_with_alpha (gimage));
|
||||
dest_type = (dest_drawable ?
|
||||
gimp_drawable_type (dest_drawable) :
|
||||
gimp_image_base_type_with_alpha (dest_gimage));
|
||||
|
||||
switch (type)
|
||||
switch (src_type)
|
||||
{
|
||||
case GIMP_RGB:
|
||||
switch (drawable_type)
|
||||
switch (dest_type)
|
||||
{
|
||||
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
|
||||
/* Straight copy */
|
||||
|
@ -1571,15 +1586,17 @@ gimp_image_transform_color (const GimpImage *gimage,
|
|||
*dest++ = *src++;
|
||||
*dest++ = *src++;
|
||||
break;
|
||||
|
||||
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
|
||||
/* NTSC conversion */
|
||||
*dest = INTENSITY (src[RED_PIX],
|
||||
src[GREEN_PIX],
|
||||
src[BLUE_PIX]);
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
|
||||
/* Least squares method */
|
||||
*dest = gimp_image_color_hash_rgb_to_indexed (gimage,
|
||||
*dest = gimp_image_color_hash_rgb_to_indexed (dest_gimage,
|
||||
src[RED_PIX],
|
||||
src[GREEN_PIX],
|
||||
src[BLUE_PIX]);
|
||||
|
@ -1588,7 +1605,7 @@ gimp_image_transform_color (const GimpImage *gimage,
|
|||
break;
|
||||
|
||||
case GIMP_GRAY:
|
||||
switch (drawable_type)
|
||||
switch (dest_type)
|
||||
{
|
||||
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
|
||||
/* Gray to RG&B */
|
||||
|
@ -1596,13 +1613,15 @@ gimp_image_transform_color (const GimpImage *gimage,
|
|||
*dest++ = *src;
|
||||
*dest++ = *src;
|
||||
break;
|
||||
|
||||
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
|
||||
/* Straight copy */
|
||||
*dest = *src;
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
|
||||
/* Least squares method */
|
||||
*dest = gimp_image_color_hash_rgb_to_indexed (gimage,
|
||||
*dest = gimp_image_color_hash_rgb_to_indexed (dest_gimage,
|
||||
src[GRAY_PIX],
|
||||
src[GRAY_PIX],
|
||||
src[GRAY_PIX]);
|
||||
|
|
|
@ -317,15 +317,15 @@ void gimp_image_get_foreground (const GimpImage *gimage,
|
|||
void gimp_image_get_background (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *bg);
|
||||
void gimp_image_get_color (const GimpImage *gimage,
|
||||
GimpImageType d_type,
|
||||
guchar *rgb,
|
||||
guchar *src);
|
||||
void gimp_image_transform_color (const GimpImage *gimage,
|
||||
const GimpDrawable *drawable,
|
||||
guchar *src,
|
||||
void gimp_image_get_color (const GimpImage *src_gimage,
|
||||
GimpImageType src_type,
|
||||
const guchar *src,
|
||||
guchar *rgb);
|
||||
void gimp_image_transform_color (const GimpImage *dest_gimage,
|
||||
const GimpDrawable *dest_drawable,
|
||||
guchar *dest,
|
||||
GimpImageBaseType type);
|
||||
GimpImageBaseType src_type,
|
||||
const guchar *src);
|
||||
|
||||
|
||||
/* shadow tiles */
|
||||
|
|
|
@ -461,7 +461,7 @@ gimp_image_map_get_color_at (GimpImageMap *image_map,
|
|||
|
||||
gimp_image_get_color (gimp_item_get_image (GIMP_ITEM (image_map->drawable)),
|
||||
gimp_drawable_type (image_map->drawable),
|
||||
dest, src);
|
||||
src, dest);
|
||||
|
||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (image_map->drawable)))
|
||||
dest[3] = src[gimp_drawable_bytes (image_map->drawable) - 1];
|
||||
|
|
|
@ -736,8 +736,9 @@ gimp_layer_transform_color (GimpImage *gimage,
|
|||
for (i = 0; i < layerPR->w; i++)
|
||||
{
|
||||
gimp_image_transform_color (gimage, drawable,
|
||||
src + (i * bufPR->bytes),
|
||||
dest + (i * layerPR->bytes), type);
|
||||
dest + (i * layerPR->bytes),
|
||||
type,
|
||||
src + (i * bufPR->bytes));
|
||||
/* copy alpha channel */
|
||||
dest[(i + 1) * layerPR->bytes - 1] = src[(i + 1) * bufPR->bytes - 1];
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ gimp_palette_import_from_image (GimpImage *gimage,
|
|||
for (j = 0; j < imagePR.w; j++)
|
||||
{
|
||||
/* Get the rgb values for the color */
|
||||
gimp_image_get_color (gimage, d_type, rgb, idata);
|
||||
gimp_image_get_color (gimage, d_type, idata, rgb);
|
||||
memcpy (rgb_real, rgb, MAX_CHANNELS); /* Structure copy */
|
||||
|
||||
rgb[0] = (rgb[0] / threshold) * threshold;
|
||||
|
|
|
@ -193,7 +193,7 @@ gimp_image_projection_get_color_at (GimpImage *gimage,
|
|||
tile = tile_manager_get_tile (gimp_image_projection (gimage), x, y,
|
||||
TRUE, FALSE);
|
||||
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
||||
gimp_image_get_color (gimage, gimp_image_projection_type (gimage), dest, src);
|
||||
gimp_image_get_color (gimage, gimp_image_projection_type (gimage), src, dest);
|
||||
|
||||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
||||
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
||||
|
|
|
@ -1998,37 +1998,6 @@ extract_from_indexed_pixels (guchar *src,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
map_to_color (guint src_type,
|
||||
const guchar *cmap,
|
||||
const guchar *src,
|
||||
guchar *rgb)
|
||||
{
|
||||
switch (src_type)
|
||||
{
|
||||
case 0: /* RGB */
|
||||
/* Straight copy */
|
||||
*rgb++ = *src++;
|
||||
*rgb++ = *src++;
|
||||
*rgb = *src;
|
||||
break;
|
||||
case 1: /* GRAY */
|
||||
*rgb++ = *src;
|
||||
*rgb++ = *src;
|
||||
*rgb = *src;
|
||||
break;
|
||||
case 2: /* INDEXED */
|
||||
{
|
||||
gint index = *src * 3;
|
||||
*rgb++ = cmap [index++];
|
||||
*rgb++ = cmap [index++];
|
||||
*rgb = cmap [index++];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/* REGION FUNCTIONS */
|
||||
/**************************************************/
|
||||
|
|
|
@ -267,16 +267,6 @@ void extract_from_indexed_pixels (guchar *src,
|
|||
guint has_alpha);
|
||||
|
||||
|
||||
/* variable source to RGB color mapping
|
||||
* src_type == 0 (RGB)
|
||||
* src_type == 1 (GRAY)
|
||||
* src_type == 2 (INDEXED)
|
||||
*/
|
||||
void map_to_color (guint src_type,
|
||||
const guchar *cmap,
|
||||
const guchar *src,
|
||||
guchar *rgb);
|
||||
|
||||
/* Region functions */
|
||||
void color_region (PixelRegion *dest,
|
||||
const guchar *color);
|
||||
|
|
|
@ -478,8 +478,8 @@ gimp_clone_line_image (GimpImage *dest,
|
|||
|
||||
while (width--)
|
||||
{
|
||||
gimp_image_get_color (src, gimp_drawable_type (s_drawable), rgb, s);
|
||||
gimp_image_transform_color (dest, d_drawable, rgb, d, GIMP_RGB);
|
||||
gimp_image_get_color (src, gimp_drawable_type (s_drawable), s, rgb);
|
||||
gimp_image_transform_color (dest, d_drawable, d, GIMP_RGB, rgb);
|
||||
|
||||
if (has_alpha)
|
||||
d[dest_alpha] = s[src_alpha];
|
||||
|
@ -528,7 +528,7 @@ gimp_clone_line_pattern (GimpImage *dest,
|
|||
{
|
||||
p = pat + ((i + x) % pattern->mask->width) * pat_bytes;
|
||||
|
||||
gimp_image_transform_color (dest, drawable, p, d, color_type);
|
||||
gimp_image_transform_color (dest, drawable, d, color_type, p);
|
||||
|
||||
if (pat_bytes == 2 || pat_bytes == 4)
|
||||
d[alpha] = p[pat_bytes - 1];
|
||||
|
|
|
@ -2043,7 +2043,7 @@ paint_line_pixmap_mask (GimpImage *dest,
|
|||
d[byte_loop] *= alpha;
|
||||
|
||||
/* printf("i: %i d->r: %i d->g: %i d->b: %i d->a: %i\n",i,(int)d[0], (int)d[1], (int)d[2], (int)d[3]); */
|
||||
gimp_image_transform_color (dest, drawable, p, d, GIMP_RGB);
|
||||
gimp_image_transform_color (dest, drawable, d, GIMP_RGB, p);
|
||||
d += bytes;
|
||||
}
|
||||
}
|
||||
|
@ -2059,7 +2059,7 @@ paint_line_pixmap_mask (GimpImage *dest,
|
|||
/* multiply alpha into the pixmap data */
|
||||
/* maybe we could do this at tool creation or brush switch time? */
|
||||
/* and compute it for the whole brush at once and cache it? */
|
||||
gimp_image_transform_color (dest, drawable, p, d, GIMP_RGB);
|
||||
gimp_image_transform_color (dest, drawable, d, GIMP_RGB, p);
|
||||
d += bytes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -478,8 +478,8 @@ gimp_clone_line_image (GimpImage *dest,
|
|||
|
||||
while (width--)
|
||||
{
|
||||
gimp_image_get_color (src, gimp_drawable_type (s_drawable), rgb, s);
|
||||
gimp_image_transform_color (dest, d_drawable, rgb, d, GIMP_RGB);
|
||||
gimp_image_get_color (src, gimp_drawable_type (s_drawable), s, rgb);
|
||||
gimp_image_transform_color (dest, d_drawable, d, GIMP_RGB, rgb);
|
||||
|
||||
if (has_alpha)
|
||||
d[dest_alpha] = s[src_alpha];
|
||||
|
@ -528,7 +528,7 @@ gimp_clone_line_pattern (GimpImage *dest,
|
|||
{
|
||||
p = pat + ((i + x) % pattern->mask->width) * pat_bytes;
|
||||
|
||||
gimp_image_transform_color (dest, drawable, p, d, color_type);
|
||||
gimp_image_transform_color (dest, drawable, d, color_type, p);
|
||||
|
||||
if (pat_bytes == 2 || pat_bytes == 4)
|
||||
d[alpha] = p[pat_bytes - 1];
|
||||
|
|
Loading…
Reference in New Issue