mirror of https://github.com/GNOME/gimp.git
pass src_bytes and dest_bytes to these functions instead of just the
2005-08-09 Michael Natterer <mitch@gimp.org> * app/paint-funcs/paint-funcs.[ch] (extract_from_inten_pixels) (extract_from_indexed_pixels): pass src_bytes and dest_bytes to these functions instead of just the source's bytes and whether it has an alpha. Honor dest_bytes when extracting instead of crashing by always asuming that the destination has alpha. Fixes bug #312392. (extract_from_region): removed has_alpha paramater. pass src->bytes and dest->bytes to above functions. * app/core/gimpselection.c (gimp_selection_extract): changed accordingly.
This commit is contained in:
parent
ad77d59c97
commit
fa74cbcd15
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2005-08-09 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/paint-funcs/paint-funcs.[ch] (extract_from_inten_pixels)
|
||||
(extract_from_indexed_pixels): pass src_bytes and dest_bytes to
|
||||
these functions instead of just the source's bytes and whether it
|
||||
has an alpha. Honor dest_bytes when extracting instead of crashing
|
||||
by always asuming that the destination has alpha.
|
||||
Fixes bug #312392.
|
||||
|
||||
(extract_from_region): removed has_alpha paramater. pass
|
||||
src->bytes and dest->bytes to above functions.
|
||||
|
||||
* app/core/gimpselection.c (gimp_selection_extract): changed
|
||||
accordingly.
|
||||
|
||||
2005-08-09 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* cursors/gimp-tool-cursors.xcf: changed path tool cursor to
|
||||
|
|
|
@ -725,8 +725,7 @@ gimp_selection_extract (GimpChannel *selection,
|
|||
|
||||
extract_from_region (&srcPR, &destPR, &maskPR,
|
||||
gimp_drawable_cmap (drawable),
|
||||
bg_color, base_type,
|
||||
gimp_drawable_has_alpha (drawable), cut_image);
|
||||
bg_color, base_type, cut_image);
|
||||
|
||||
if (cut_image)
|
||||
{
|
||||
|
@ -743,8 +742,7 @@ gimp_selection_extract (GimpChannel *selection,
|
|||
if (base_type == GIMP_INDEXED && !keep_indexed)
|
||||
extract_from_region (&srcPR, &destPR, NULL,
|
||||
gimp_drawable_cmap (drawable),
|
||||
bg_color, base_type,
|
||||
gimp_drawable_has_alpha (drawable), FALSE);
|
||||
bg_color, base_type, FALSE);
|
||||
/* If the layer doesn't have an alpha channel, add one */
|
||||
else if (bytes > srcPR.bytes)
|
||||
add_alpha_region (&srcPR, &destPR);
|
||||
|
|
|
@ -1919,11 +1919,10 @@ extract_from_inten_pixels (guchar *src,
|
|||
const guchar *bg,
|
||||
gboolean cut,
|
||||
guint length,
|
||||
guint bytes,
|
||||
gboolean has_alpha)
|
||||
guint src_bytes,
|
||||
guint dest_bytes)
|
||||
{
|
||||
gint b, alpha;
|
||||
gint dest_bytes;
|
||||
const guchar *m;
|
||||
gint tmp;
|
||||
|
||||
|
@ -1932,14 +1931,14 @@ extract_from_inten_pixels (guchar *src,
|
|||
else
|
||||
m = &no_mask;
|
||||
|
||||
alpha = (has_alpha) ? bytes - 1 : bytes;
|
||||
dest_bytes = (has_alpha) ? bytes : bytes + 1;
|
||||
alpha = HAS_ALPHA (src_bytes) ? src_bytes - 1 : src_bytes;
|
||||
|
||||
while (length --)
|
||||
{
|
||||
for (b = 0; b < alpha; b++)
|
||||
dest[b] = src[b];
|
||||
|
||||
if (has_alpha)
|
||||
if (HAS_ALPHA (src_bytes))
|
||||
{
|
||||
dest[alpha] = INT_MULT(*m, src[alpha], tmp);
|
||||
if (cut)
|
||||
|
@ -1947,16 +1946,18 @@ extract_from_inten_pixels (guchar *src,
|
|||
}
|
||||
else
|
||||
{
|
||||
dest[alpha] = *m;
|
||||
if (HAS_ALPHA (dest_bytes))
|
||||
dest[alpha] = *m;
|
||||
|
||||
if (cut)
|
||||
for (b = 0; b < bytes; b++)
|
||||
for (b = 0; b < src_bytes; b++)
|
||||
src[b] = INT_BLEND(bg[b], src[b], *m, tmp);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
m++;
|
||||
|
||||
src += bytes;
|
||||
src += src_bytes;
|
||||
dest += dest_bytes;
|
||||
}
|
||||
}
|
||||
|
@ -1970,8 +1971,8 @@ extract_from_indexed_pixels (guchar *src,
|
|||
const guchar *bg,
|
||||
gboolean cut,
|
||||
guint length,
|
||||
guint bytes,
|
||||
gboolean has_alpha)
|
||||
guint src_bytes,
|
||||
guint dest_bytes)
|
||||
{
|
||||
gint b;
|
||||
gint index;
|
||||
|
@ -1989,7 +1990,7 @@ extract_from_indexed_pixels (guchar *src,
|
|||
for (b = 0; b < 3; b++)
|
||||
dest[b] = cmap[index + b];
|
||||
|
||||
if (has_alpha)
|
||||
if (HAS_ALPHA (src_bytes))
|
||||
{
|
||||
dest[3] = INT_MULT (*m, src[1], t);
|
||||
if (cut)
|
||||
|
@ -1997,7 +1998,9 @@ extract_from_indexed_pixels (guchar *src,
|
|||
}
|
||||
else
|
||||
{
|
||||
dest[3] = *m;
|
||||
if (HAS_ALPHA (dest_bytes))
|
||||
dest[3] = *m;
|
||||
|
||||
if (cut)
|
||||
src[0] = (*m > 127) ? bg[0] : src[0];
|
||||
}
|
||||
|
@ -2005,8 +2008,8 @@ extract_from_indexed_pixels (guchar *src,
|
|||
if (mask)
|
||||
m++;
|
||||
|
||||
src += bytes;
|
||||
dest += 4;
|
||||
src += src_bytes;
|
||||
dest += dest_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2351,7 +2354,6 @@ extract_from_region (PixelRegion *src,
|
|||
const guchar *cmap,
|
||||
const guchar *bg,
|
||||
GimpImageBaseType type,
|
||||
gboolean has_alpha,
|
||||
gboolean cut)
|
||||
{
|
||||
gint h;
|
||||
|
@ -2374,12 +2376,12 @@ extract_from_region (PixelRegion *src,
|
|||
case GIMP_RGB:
|
||||
case GIMP_GRAY:
|
||||
extract_from_inten_pixels (s, d, m, bg, cut, src->w,
|
||||
src->bytes, has_alpha);
|
||||
src->bytes, dest->bytes);
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED:
|
||||
extract_from_indexed_pixels (s, d, m, cmap, bg, cut, src->w,
|
||||
src->bytes, has_alpha);
|
||||
src->bytes, dest->bytes);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -283,8 +283,8 @@ void extract_from_inten_pixels (guchar *src,
|
|||
const guchar *bg,
|
||||
gboolean cut,
|
||||
guint length,
|
||||
guint bytes,
|
||||
gboolean has_alpha);
|
||||
guint src_bytes,
|
||||
guint dest_bytes);
|
||||
|
||||
/* extract information from indexed pixels based on
|
||||
* a mask.
|
||||
|
@ -296,8 +296,8 @@ void extract_from_indexed_pixels (guchar *src,
|
|||
const guchar *bg,
|
||||
gboolean cut,
|
||||
guint length,
|
||||
guint bytes,
|
||||
gboolean has_alpha);
|
||||
guint src_bytes,
|
||||
guint dest_bytes);
|
||||
|
||||
|
||||
/* Region functions */
|
||||
|
@ -345,7 +345,6 @@ void extract_from_region (PixelRegion *src,
|
|||
const guchar *cmap,
|
||||
const guchar *bg,
|
||||
GimpImageBaseType type,
|
||||
gboolean has_alpha,
|
||||
gboolean cut);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue