2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-11-19 11:06:09 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is supposed to contain the generic (read: C) implementation
|
2004-01-28 11:58:52 +08:00
|
|
|
* of the pixel fiddling paint-functions.
|
2001-11-19 11:06:09 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PAINT_FUNCS_GENERIC_H__
|
|
|
|
#define __PAINT_FUNCS_GENERIC_H__
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
color_pixels (guchar *dest,
|
2004-04-15 20:38:54 +08:00
|
|
|
const guchar *color,
|
|
|
|
guint w,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
switch (bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
memset (dest, *color, w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
#if defined(sparc) || defined(__sparc__)
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
|
|
|
const guchar c0 = color[0];
|
|
|
|
const guchar c1 = color[1];
|
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
dest[0] = c0;
|
|
|
|
dest[1] = c1;
|
|
|
|
dest += 2;
|
|
|
|
}
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
#else
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
|
|
|
const guint16 shortc = ((const guint16 *) color)[0];
|
|
|
|
guint16 *shortd = (guint16 *) dest;
|
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
*shortd = shortc;
|
|
|
|
shortd++;
|
|
|
|
}
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
#endif /* sparc || __sparc__ */
|
|
|
|
break;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
case 3:
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
|
|
|
const guchar c0 = color[0];
|
|
|
|
const guchar c1 = color[1];
|
|
|
|
const guchar c2 = color[2];
|
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
dest[0] = c0;
|
|
|
|
dest[1] = c1;
|
|
|
|
dest[2] = c2;
|
|
|
|
dest += 3;
|
|
|
|
}
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
break;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
case 4:
|
|
|
|
#if defined(sparc) || defined(__sparc__)
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
|
|
|
const guchar c0 = color[0];
|
|
|
|
const guchar c1 = color[1];
|
|
|
|
const guchar c2 = color[2];
|
|
|
|
const guchar c3 = color[3];
|
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
dest[0] = c0;
|
|
|
|
dest[1] = c1;
|
|
|
|
dest[2] = c2;
|
|
|
|
dest[3] = c3;
|
|
|
|
dest += 4;
|
|
|
|
}
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
#else
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
|
|
|
const guint32 longc = ((const guint32 *) color)[0];
|
|
|
|
guint32 *longd = (guint32 *) dest;
|
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
*longd = longc;
|
|
|
|
longd++;
|
|
|
|
}
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
#endif /* sparc || __sparc__ */
|
|
|
|
break;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
default:
|
|
|
|
while (w--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
|
|
|
memcpy (dest, color, bytes);
|
|
|
|
dest += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-28 04:04:07 +08:00
|
|
|
void
|
|
|
|
color_pixels_mask (guchar *dest,
|
2006-04-25 20:19:24 +08:00
|
|
|
const guchar *mask,
|
2003-09-28 04:04:07 +08:00
|
|
|
const guchar *color,
|
|
|
|
guint w,
|
|
|
|
guint bytes)
|
|
|
|
{
|
|
|
|
guchar c0, c1, c2;
|
|
|
|
gint alpha;
|
|
|
|
|
|
|
|
alpha = HAS_ALPHA (bytes) ? bytes - 1 : bytes;
|
|
|
|
|
|
|
|
switch (bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
memset (dest, *color, w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
c0 = color[0];
|
|
|
|
while (w--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
|
|
|
dest[0] = c0;
|
|
|
|
dest[1] = *mask++;
|
|
|
|
dest += 2;
|
|
|
|
}
|
2003-09-28 04:04:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
c0 = color[0];
|
|
|
|
c1 = color[1];
|
|
|
|
c2 = color[2];
|
|
|
|
while (w--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
|
|
|
dest[0] = c0;
|
|
|
|
dest[1] = c1;
|
|
|
|
dest[2] = c2;
|
|
|
|
dest += 3;
|
|
|
|
}
|
2003-09-28 04:04:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
c0 = color[0];
|
|
|
|
c1 = color[1];
|
|
|
|
c2 = color[2];
|
|
|
|
while (w--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
|
|
|
dest[0] = c0;
|
|
|
|
dest[1] = c1;
|
|
|
|
dest[2] = c2;
|
|
|
|
dest[3] = *mask++;
|
|
|
|
dest += 4;
|
|
|
|
}
|
2003-09-28 04:04:07 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-25 20:19:24 +08:00
|
|
|
pattern_pixels_mask (guchar *dest,
|
|
|
|
const guchar *mask,
|
|
|
|
TempBuf *pattern,
|
|
|
|
guint w,
|
|
|
|
guint bytes,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guint alpha = HAS_ALPHA (bytes) ? bytes - 1 : bytes;
|
|
|
|
const guchar *pat;
|
|
|
|
guint i;
|
2003-09-28 04:04:07 +08:00
|
|
|
|
|
|
|
/* Get a pointer to the appropriate scanline of the pattern buffer */
|
2008-12-13 18:35:53 +08:00
|
|
|
pat = (temp_buf_get_data (pattern) +
|
2003-09-28 04:04:07 +08:00
|
|
|
(y % pattern->height) * pattern->width * pattern->bytes);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* image data = pattern data for all but alpha
|
|
|
|
*
|
|
|
|
* If (image has alpha)
|
|
|
|
* if (there's a mask)
|
|
|
|
* image data = mask for alpha;
|
2008-10-14 02:51:32 +08:00
|
|
|
* else
|
|
|
|
* image data = opaque for alpha.
|
|
|
|
*
|
|
|
|
* if (pattern has alpha)
|
|
|
|
* multiply existing alpha channel by pattern alpha
|
|
|
|
* (normalised to (0..1))
|
|
|
|
*/
|
2002-11-06 03:33:59 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
for (i = 0; i < w; i++)
|
2002-11-06 03:33:59 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
const guchar *p = pat + ((i + x) % pattern->width) * pattern->bytes;
|
|
|
|
guint b;
|
2006-04-25 20:19:24 +08:00
|
|
|
|
2002-11-06 03:33:59 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
2008-10-14 02:51:32 +08:00
|
|
|
dest[b] = p[b];
|
|
|
|
|
|
|
|
if (HAS_ALPHA (bytes))
|
2002-11-06 03:33:59 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
if (mask)
|
|
|
|
dest[alpha] = *mask++;
|
|
|
|
else
|
|
|
|
dest[alpha] = OPAQUE_OPACITY;
|
2006-04-25 20:19:24 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
if (HAS_ALPHA (pattern->bytes))
|
|
|
|
dest[alpha] = (guchar) (dest[alpha] *
|
|
|
|
p[alpha] / (gdouble) OPAQUE_OPACITY);
|
2002-11-06 03:33:59 +08:00
|
|
|
}
|
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
dest += bytes;
|
2002-11-06 03:33:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
/*
|
|
|
|
* blend_pixels patched 8-24-05 to fix bug #163721. Note that this change
|
|
|
|
* causes the function to treat src1 and src2 asymmetrically. This gives the
|
|
|
|
* right behavior for the smudge tool, which is the only user of this function
|
|
|
|
* at the time of patching. If you want to use the function for something
|
|
|
|
* else, caveat emptor.
|
|
|
|
*/
|
|
|
|
inline void
|
|
|
|
blend_pixels (const guchar *src1,
|
|
|
|
const guchar *src2,
|
|
|
|
guchar *dest,
|
|
|
|
guchar blend,
|
|
|
|
guint w,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
if (HAS_ALPHA (bytes))
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
const guint blend1 = 255 - blend;
|
|
|
|
const guint blend2 = blend + 1;
|
|
|
|
const guint c = bytes - 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
const gint a1 = blend1 * src1[c];
|
|
|
|
const gint a2 = blend2 * src2[c];
|
|
|
|
const gint a = a1 + a2;
|
|
|
|
guint b;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
if (!a)
|
|
|
|
{
|
|
|
|
for (b = 0; b < bytes; b++)
|
|
|
|
dest[b] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (b = 0; b < c; b++)
|
|
|
|
dest[b] =
|
|
|
|
src1[b] + (src1[b] * a1 + src2[b] * a2 - a * src1[b]) / a;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
dest[c] = a >> 8;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
src1 += bytes;
|
|
|
|
src2 += bytes;
|
|
|
|
dest += bytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
const guchar blend1 = 255 - blend;
|
2006-04-25 20:19:24 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
while (w--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
guint b;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
|
|
|
dest[b] =
|
|
|
|
src1[b] + (src1[b] * blend1 + src2[b] * blend - src1[b] * 255) / 255;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
src1 += bytes;
|
|
|
|
src2 += bytes;
|
|
|
|
dest += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
inline void
|
|
|
|
shade_pixels (const guchar *src,
|
|
|
|
guchar *dest,
|
|
|
|
const guchar *col,
|
|
|
|
guchar blend,
|
|
|
|
guint w,
|
|
|
|
guint bytes,
|
|
|
|
gboolean has_alpha)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
const guchar blend2 = (255 - blend);
|
|
|
|
const guint alpha = (has_alpha) ? bytes - 1 : bytes;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
while (w--)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
2008-10-14 02:51:32 +08:00
|
|
|
dest[b] = (src[b] * blend2 + col[b] * blend) / 255;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
if (has_alpha)
|
|
|
|
dest[alpha] = src[alpha]; /* alpha channel */
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
src += bytes;
|
|
|
|
dest += bytes;
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
inline void
|
|
|
|
extract_alpha_pixels (const guchar *src,
|
|
|
|
const guchar *mask,
|
|
|
|
guchar *dest,
|
|
|
|
guint w,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
const guint alpha = bytes - 1;
|
2003-06-02 22:21:01 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
if (mask)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
const guchar *m = mask;
|
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
while (w--)
|
2003-06-02 22:21:01 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
gint tmp;
|
2003-06-02 22:21:01 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
*dest++ = INT_MULT(src[alpha], *m, tmp);
|
|
|
|
m++;
|
|
|
|
src += bytes;
|
2003-06-02 22:21:01 +08:00
|
|
|
}
|
2008-10-14 02:51:32 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (w--)
|
2003-06-02 22:21:01 +08:00
|
|
|
{
|
2008-10-14 02:51:32 +08:00
|
|
|
gint tmp;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
*dest++ = INT_MULT(src[alpha], OPAQUE_OPACITY, tmp);
|
|
|
|
src += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 02:51:32 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
static inline void
|
2006-04-25 20:19:24 +08:00
|
|
|
replace_pixels (const guchar *src1,
|
|
|
|
const guchar *src2,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
2006-04-25 20:19:24 +08:00
|
|
|
const guchar *mask,
|
2004-04-15 20:38:54 +08:00
|
|
|
gint length,
|
|
|
|
gint opacity,
|
|
|
|
const gboolean *affect,
|
|
|
|
gint bytes1,
|
|
|
|
gint bytes2)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const gint alpha = bytes1 - 1;
|
|
|
|
const gdouble norm_opacity = opacity * (1.0 / 65536.0);
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
if (bytes1 != bytes2)
|
|
|
|
{
|
|
|
|
g_warning ("replace_pixels only works on commensurate pixel regions");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
gdouble mask_val = mask[0] * norm_opacity;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2006-04-25 20:19:24 +08:00
|
|
|
/* calculate new alpha first. */
|
|
|
|
gint s1_a = src1[alpha];
|
|
|
|
gint s2_a = src2[alpha];
|
|
|
|
gdouble a_val = s1_a + mask_val * (s2_a - s1_a);
|
|
|
|
|
|
|
|
if (a_val == 0)
|
|
|
|
/* In any case, write out versions of the blending function */
|
|
|
|
/* that result when combinations of s1_a, s2_a, and */
|
|
|
|
/* mask_val --> 0 (or mask_val -->1) */
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
/* Case 1: s1_a, s2_a, AND mask_val all approach 0+: */
|
2004-04-15 20:38:54 +08:00
|
|
|
/* Case 2: s1_a AND s2_a both approach 0+, regardless of mask_val: */
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
if (s1_a + s2_a == 0.0)
|
|
|
|
{
|
|
|
|
for (b = 0; b < alpha; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint new_val = 0.5 + (gdouble) src1[b] +
|
2004-04-15 20:38:54 +08:00
|
|
|
mask_val * ((gdouble) src2[b] - (gdouble) src1[b]);
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
/* Case 3: mask_val AND s1_a both approach 0+, regardless of s2_a */
|
2001-11-19 11:06:09 +08:00
|
|
|
else if (s1_a + mask_val == 0.0)
|
|
|
|
{
|
|
|
|
for (b = 0; b < alpha; b++)
|
2006-04-25 20:19:24 +08:00
|
|
|
dest[b] = src1[b];
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
/* Case 4: mask_val -->1 AND s2_a -->0, regardless of s1_a */
|
2001-11-19 11:06:09 +08:00
|
|
|
else if (1.0 - mask_val + s2_a == 0.0)
|
|
|
|
{
|
|
|
|
for (b = 0; b < alpha; b++)
|
2006-04-25 20:19:24 +08:00
|
|
|
dest[b] = affect[b] ? src2[b] : src1[b];
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
2004-04-15 20:38:54 +08:00
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
else
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gdouble a_recip = 1.0 / a_val;
|
|
|
|
/* possible optimization: fold a_recip into s1_a and s2_a */
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint new_val = 0.5 + a_recip * (src1[b] * s1_a + mask_val *
|
|
|
|
(src2[b] * s2_a - src1[b] * s1_a));
|
2004-04-15 20:38:54 +08:00
|
|
|
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dest[alpha] = affect[alpha] ? a_val + 0.5: s1_a;
|
|
|
|
src1 += bytes1;
|
|
|
|
src2 += bytes2;
|
|
|
|
dest += bytes2;
|
|
|
|
mask++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
swap_pixels (guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
guint length)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
while (length--)
|
|
|
|
{
|
2005-09-28 06:27:26 +08:00
|
|
|
guchar tmp = *dest;
|
|
|
|
|
|
|
|
*dest = *src;
|
|
|
|
*src = tmp;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
src++;
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
scale_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
gint scale)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
gint tmp;
|
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
|
|
|
*dest++ = (guchar) INT_MULT (*src, scale, tmp);
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
add_alpha_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guint alpha = bytes + 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
dest[b] = src[b];
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
dest[b] = OPAQUE_OPACITY;
|
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
dest += alpha;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
flatten_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
const guchar *bg,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guint alpha = bytes - 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
2006-04-25 20:19:24 +08:00
|
|
|
{
|
|
|
|
gint t1, t2;
|
|
|
|
|
|
|
|
dest[b] = (INT_MULT (src[b], src[alpha], t1) +
|
|
|
|
INT_MULT (bg[b], (255 - src[alpha]), t2));
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
dest += alpha;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
gray_to_rgb_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const gboolean has_alpha = (bytes == 2) ? TRUE : FALSE;
|
|
|
|
const gint dest_bytes = (has_alpha) ? 4 : 3;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
dest[b] = src[0];
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
if (has_alpha)
|
2004-04-15 20:38:54 +08:00
|
|
|
dest[3] = src[1];
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
dest += dest_bytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
apply_mask_to_alpha_channel (guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
const guchar *mask,
|
|
|
|
guint opacity,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
src += bytes - 1;
|
|
|
|
|
|
|
|
if (opacity == 255)
|
|
|
|
{
|
|
|
|
while (length --)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
glong tmp;
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
*src = INT_MULT(*src, *mask, tmp);
|
|
|
|
mask++;
|
|
|
|
src += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (length --)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
glong tmp;
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
*src = INT_MULT3(*src, *mask, opacity, tmp);
|
|
|
|
mask++;
|
|
|
|
src += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
2004-06-06 00:21:41 +08:00
|
|
|
combine_mask_and_alpha_channel_stipple (guchar *src,
|
|
|
|
const guchar *mask,
|
|
|
|
guint opacity,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2004-06-06 00:21:41 +08:00
|
|
|
/* align with alpha channel */
|
|
|
|
src += bytes - 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
if (opacity != 255)
|
|
|
|
while (length --)
|
2004-06-06 00:21:41 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint tmp;
|
|
|
|
gint mask_val = INT_MULT(*mask, opacity, tmp);
|
|
|
|
|
2004-06-06 00:21:41 +08:00
|
|
|
*src = *src + INT_MULT((255 - *src) , mask_val, tmp);
|
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
mask++;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
else
|
|
|
|
while (length --)
|
2004-06-06 00:21:41 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint tmp;
|
|
|
|
|
2004-06-06 00:21:41 +08:00
|
|
|
*src = *src + INT_MULT((255 - *src) , *mask, tmp);
|
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
mask++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
combine_mask_and_alpha_channel_stroke (guchar *src,
|
|
|
|
const guchar *mask,
|
|
|
|
guint opacity,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
|
|
|
{
|
|
|
|
/* align with alpha channel */
|
|
|
|
src += bytes - 1;
|
|
|
|
|
|
|
|
if (opacity != 255)
|
|
|
|
while (length --)
|
|
|
|
{
|
|
|
|
if (opacity > *src)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint tmp;
|
|
|
|
gint mask_val = INT_MULT (*mask, opacity, tmp);
|
|
|
|
|
|
|
|
*src = *src + INT_MULT ((opacity - *src) , mask_val, tmp);
|
2004-06-06 00:21:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
mask++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint tmp;
|
|
|
|
|
|
|
|
*src = *src + INT_MULT ((255 - *src) , *mask, tmp);
|
2004-06-06 00:21:41 +08:00
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
mask++;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
copy_gray_to_inten_a_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guint alpha = bytes - 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
dest[b] = *src;
|
2001-11-19 11:06:09 +08:00
|
|
|
dest[b] = OPAQUE_OPACITY;
|
|
|
|
|
|
|
|
src ++;
|
|
|
|
dest += bytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
initial_channel_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guint alpha = bytes - 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
dest[b] = src[0];
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
dest[alpha] = OPAQUE_OPACITY;
|
|
|
|
|
|
|
|
dest += bytes;
|
|
|
|
src ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
initial_indexed_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
const guchar *cmap,
|
|
|
|
guint length)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
/* This function assumes always that we're mapping from
|
|
|
|
* an RGB colormap to an RGBA image...
|
|
|
|
*/
|
|
|
|
while (length--)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint col_index = *src++ * 3;
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
*dest++ = cmap[col_index++];
|
|
|
|
*dest++ = cmap[col_index++];
|
|
|
|
*dest++ = cmap[col_index++];
|
|
|
|
*dest++ = OPAQUE_OPACITY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
initial_indexed_a_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
const guchar *mask,
|
|
|
|
const guchar *no_mask,
|
|
|
|
const guchar *cmap,
|
|
|
|
guint opacity,
|
|
|
|
guint length)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guchar *m = mask ? mask : no_mask;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint col_index = *src++ * 3;
|
|
|
|
glong tmp;
|
|
|
|
guchar new_alpha = INT_MULT3(*src, *m, opacity, tmp);
|
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
src++;
|
2006-04-25 20:19:24 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
*dest++ = cmap[col_index++];
|
|
|
|
*dest++ = cmap[col_index++];
|
|
|
|
*dest++ = cmap[col_index++];
|
|
|
|
/* Set the alpha channel */
|
|
|
|
*dest++ = (new_alpha > 127) ? OPAQUE_OPACITY : TRANSPARENT_OPACITY;
|
|
|
|
|
|
|
|
if (mask)
|
2004-04-15 20:38:54 +08:00
|
|
|
m++;
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
2004-04-15 20:38:54 +08:00
|
|
|
initial_inten_pixels (const guchar *src,
|
|
|
|
guchar *dest,
|
|
|
|
const guchar *mask,
|
|
|
|
const guchar *no_mask,
|
|
|
|
guint opacity,
|
|
|
|
const gboolean *affect,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
const guchar *srcp;
|
|
|
|
const gint dest_bytes = bytes + 1;
|
2006-04-25 20:19:24 +08:00
|
|
|
guchar *destp;
|
|
|
|
gint b, l;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
if (mask)
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guchar *m = mask;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
/* This function assumes the source has no alpha channel and
|
|
|
|
* the destination has an alpha channel. So dest_bytes = bytes + 1
|
|
|
|
*/
|
2004-04-15 20:38:54 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
if (bytes == 3 && affect[0] && affect[1] && affect[2])
|
|
|
|
{
|
2005-11-09 17:55:45 +08:00
|
|
|
if (!affect[bytes])
|
|
|
|
opacity = 0;
|
2004-04-15 20:38:54 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
destp = dest + bytes;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
if (opacity != 0)
|
|
|
|
while(length--)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint tmp;
|
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
dest[0] = src[0];
|
|
|
|
dest[1] = src[1];
|
|
|
|
dest[2] = src[2];
|
2006-04-25 20:19:24 +08:00
|
|
|
dest[3] = INT_MULT (opacity, *m, tmp);
|
2004-06-14 20:18:30 +08:00
|
|
|
src += bytes;
|
|
|
|
dest += dest_bytes;
|
|
|
|
m++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while(length--)
|
|
|
|
{
|
|
|
|
dest[0] = src[0];
|
|
|
|
dest[1] = src[1];
|
|
|
|
dest[2] = src[2];
|
|
|
|
dest[3] = opacity;
|
|
|
|
src += bytes;
|
|
|
|
dest += dest_bytes;
|
|
|
|
}
|
2006-04-25 20:19:24 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
return;
|
|
|
|
}
|
2004-04-15 20:38:54 +08:00
|
|
|
|
2006-04-25 20:19:24 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
2004-06-14 20:18:30 +08:00
|
|
|
{
|
|
|
|
destp = dest + b;
|
|
|
|
srcp = src + b;
|
|
|
|
l = length;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
if (affect[b])
|
|
|
|
while(l--)
|
|
|
|
{
|
|
|
|
*destp = *srcp;
|
|
|
|
srcp += bytes;
|
|
|
|
destp += dest_bytes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while(l--)
|
|
|
|
{
|
|
|
|
*destp = 0;
|
|
|
|
destp += dest_bytes;
|
|
|
|
}
|
|
|
|
}
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
/* fill the alpha channel */
|
2005-11-09 17:55:45 +08:00
|
|
|
if (!affect[bytes])
|
|
|
|
opacity = 0;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
destp = dest + bytes;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
if (opacity != 0)
|
|
|
|
while (length--)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
gint tmp;
|
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
*destp = INT_MULT(opacity , *m, tmp);
|
|
|
|
destp += dest_bytes;
|
|
|
|
m++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
*destp = opacity;
|
|
|
|
destp += dest_bytes;
|
|
|
|
}
|
|
|
|
}
|
2006-04-25 20:19:24 +08:00
|
|
|
else /* no mask */
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
|
|
|
/* This function assumes the source has no alpha channel and
|
|
|
|
* the destination has an alpha channel. So dest_bytes = bytes + 1
|
|
|
|
*/
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
if (bytes == 3 && affect[0] && affect[1] && affect[2])
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2005-11-09 17:55:45 +08:00
|
|
|
if (!affect[bytes])
|
|
|
|
opacity = 0;
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
destp = dest + bytes;
|
|
|
|
|
|
|
|
while(length--)
|
|
|
|
{
|
|
|
|
dest[0] = src[0];
|
|
|
|
dest[1] = src[1];
|
|
|
|
dest[2] = src[2];
|
|
|
|
dest[3] = opacity;
|
|
|
|
src += bytes;
|
|
|
|
dest += dest_bytes;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-06-14 20:18:30 +08:00
|
|
|
for (b = 0; b < bytes; b++)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
|
|
|
destp = dest + b;
|
|
|
|
srcp = src + b;
|
|
|
|
l = length;
|
|
|
|
|
|
|
|
if (affect[b])
|
|
|
|
while(l--)
|
|
|
|
{
|
|
|
|
*destp = *srcp;
|
|
|
|
srcp += bytes;
|
|
|
|
destp += dest_bytes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while(l--)
|
|
|
|
{
|
|
|
|
*destp = 0;
|
|
|
|
destp += dest_bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
2003-07-22 00:47:52 +08:00
|
|
|
|
|
|
|
/* fill the alpha channel */
|
2005-11-09 17:55:45 +08:00
|
|
|
if (!affect[bytes])
|
|
|
|
opacity = 0;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
destp = dest + bytes;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
while (length--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
|
|
|
*destp = opacity;
|
|
|
|
destp += dest_bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
initial_inten_a_pixels (const guchar *src,
|
2004-04-15 20:38:54 +08:00
|
|
|
guchar *dest,
|
|
|
|
const guchar *mask,
|
|
|
|
guint opacity,
|
|
|
|
const gboolean *affect,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
2001-11-19 11:06:09 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guint alpha = bytes - 1;
|
2001-11-19 11:06:09 +08:00
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
const guchar *m = mask;
|
|
|
|
|
|
|
|
while (length--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
glong tmp;
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
|
|
|
dest[b] = src[b] * affect[b];
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
/* Set the alpha channel */
|
2006-04-25 20:19:24 +08:00
|
|
|
dest[alpha] = (affect [alpha] ?
|
|
|
|
INT_MULT3(opacity, src[alpha], *m, tmp) : 0);
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
m++;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
dest += bytes;
|
|
|
|
src += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
while (length--)
|
2004-04-15 20:38:54 +08:00
|
|
|
{
|
2006-04-25 20:19:24 +08:00
|
|
|
guint b;
|
|
|
|
glong tmp;
|
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
for (b = 0; b < alpha; b++)
|
|
|
|
dest[b] = src[b] * affect[b];
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
/* Set the alpha channel */
|
2006-04-25 20:19:24 +08:00
|
|
|
dest[alpha] = (affect [alpha] ?
|
|
|
|
INT_MULT(opacity , src[alpha], tmp) : 0);
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2004-04-15 20:38:54 +08:00
|
|
|
dest += bytes;
|
|
|
|
src += bytes;
|
|
|
|
}
|
2001-11-19 11:06:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-12 07:54:49 +08:00
|
|
|
inline void
|
2006-05-16 21:11:47 +08:00
|
|
|
copy_component_pixels (const guchar *src,
|
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
guint bytes,
|
|
|
|
guint pixel)
|
2003-03-12 07:54:49 +08:00
|
|
|
{
|
|
|
|
src += pixel;
|
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
|
|
|
*dest = *src;
|
2003-07-22 00:47:52 +08:00
|
|
|
|
2003-03-12 07:54:49 +08:00
|
|
|
src += bytes;
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-16 21:11:47 +08:00
|
|
|
inline void
|
|
|
|
copy_color_pixels (const guchar *src,
|
|
|
|
guchar *dest,
|
|
|
|
guint length,
|
|
|
|
guint bytes)
|
|
|
|
{
|
|
|
|
const guint alpha = bytes - 1;
|
|
|
|
|
|
|
|
while (length --)
|
|
|
|
{
|
|
|
|
guint b;
|
|
|
|
|
|
|
|
for (b = 0; b < alpha; b++)
|
|
|
|
dest[b] = src[b];
|
|
|
|
|
|
|
|
src += bytes;
|
|
|
|
dest += bytes - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-12 07:54:49 +08:00
|
|
|
|
2001-11-19 11:06:09 +08:00
|
|
|
#endif /* __PAINT_FUNCS_GENERIC_H__ */
|