} i_fill_solid_t;
static void fill_solid(i_fill_t *, int x, int y, int width, int channels,
- i_color *, i_color *);
+ i_color *);
static void fill_solidf(i_fill_t *, int x, int y, int width, int channels,
- i_fcolor *, i_fcolor *);
+ i_fcolor *);
static void fill_solid_comb(i_fill_t *, int x, int y, int width, int channels,
- i_color *, i_color *);
+ i_color *);
static void fill_solidf_comb(i_fill_t *, int x, int y, int width,
- int channels, i_fcolor *, i_fcolor *);
+ int channels, i_fcolor *);
static i_fill_solid_t base_solid_fill =
{
i_fill_t *
i_new_fill_solidf(i_fcolor *c, int combine) {
int ch;
- i_fill_solid_t *fill = mymalloc(sizeof(i_fill_solid_t));
+ i_fill_solid_t *fill = mymalloc(sizeof(i_fill_solid_t)); /* checked 14jul05 tonyc */
if (combine) {
*fill = base_solid_fill_comb;
i_fill_t *
i_new_fill_solid(i_color *c, int combine) {
int ch;
- i_fill_solid_t *fill = mymalloc(sizeof(i_fill_solid_t));
+ i_fill_solid_t *fill = mymalloc(sizeof(i_fill_solid_t)); /* checked 14jul05 tonyc */
if (combine) {
*fill = base_solid_fill_comb;
} i_fill_hatch_t;
static void fill_hatch(i_fill_t *fill, int x, int y, int width, int channels,
- i_color *data, i_color *work);
+ i_color *data);
static void fill_hatchf(i_fill_t *fill, int x, int y, int width, int channels,
- i_fcolor *data, i_fcolor *work);
+ i_fcolor *data);
static
i_fill_t *
i_new_hatch_low(i_color *fg, i_color *bg, i_fcolor *ffg, i_fcolor *fbg,
}
static void fill_image(i_fill_t *fill, int x, int y, int width, int channels,
- i_color *data, i_color *work);
+ i_color *data);
static void fill_imagef(i_fill_t *fill, int x, int y, int width, int channels,
- i_fcolor *data, i_fcolor *work);
+ i_fcolor *data);
struct i_fill_image_t {
i_fill_t base;
i_img *src;
*/
i_fill_t *
i_new_fill_image(i_img *im, double *matrix, int xoff, int yoff, int combine) {
- struct i_fill_image_t *fill = mymalloc(sizeof(*fill));
+ struct i_fill_image_t *fill = mymalloc(sizeof(*fill)); /* checked 14jul05 tonyc */
fill->base.fill_with_color = fill_image;
fill->base.fill_with_fcolor = fill_imagef;
*/
static void
fill_solid(i_fill_t *fill, int x, int y, int width, int channels,
- i_color *data, i_color *work) {
+ i_color *data) {
while (width-- > 0) {
*data++ = T_SOLID_FILL(fill)->c;
}
*/
static void
fill_solidf(i_fill_t *fill, int x, int y, int width, int channels,
- i_fcolor *data, i_fcolor *work) {
+ i_fcolor *data) {
while (width-- > 0) {
*data++ = T_SOLID_FILL(fill)->fc;
}
*/
static void
fill_solid_comb(i_fill_t *fill, int x, int y, int width, int channels,
- i_color *data, i_color *work) {
+ i_color *data) {
i_color c = T_SOLID_FILL(fill)->c;
- int count = width;
- i_color *wstart = work;
while (width-- > 0) {
- *work++ = c;
+ *data++ = c;
}
- (fill->combine)(data, wstart, channels, count);
}
/*
*/
static void
fill_solidf_comb(i_fill_t *fill, int x, int y, int width, int channels,
- i_fcolor *data, i_fcolor *work) {
+ i_fcolor *data) {
i_fcolor c = T_SOLID_FILL(fill)->fc;
- int count = width;
- i_fcolor *wstart = work;
while (width-- > 0) {
- *work++ = c;
+ *data++ = c;
}
- (fill->combinef)(data, wstart, channels, count);
}
/*
i_new_hatch_low(i_color *fg, i_color *bg, i_fcolor *ffg, i_fcolor *fbg,
int combine, int hatch, unsigned char *cust_hatch,
int dx, int dy) {
- i_fill_hatch_t *fill = mymalloc(sizeof(i_fill_hatch_t));
+ i_fill_hatch_t *fill = mymalloc(sizeof(i_fill_hatch_t)); /* checked 14jul05 tonyc */
fill->base.fill_with_color = fill_hatch;
fill->base.fill_with_fcolor = fill_hatchf;
=cut
*/
static void fill_hatch(i_fill_t *fill, int x, int y, int width, int channels,
- i_color *data, i_color *work) {
+ i_color *data) {
i_fill_hatch_t *f = (i_fill_hatch_t *)fill;
int byte = f->hatch[(y + f->dy) & 7];
int xpos = (x + f->dx) & 7;
int mask = 128 >> xpos;
- if (fill->combine) {
- int count = width;
- i_color *wstart = work;
-
- while (count-- > 0) {
- *work++ = (byte & mask) ? f->fg : f->bg;
-
- if ((mask >>= 1) == 0)
- mask = 128;
- }
- (fill->combine)(data, wstart, channels, width);
- }
- else {
- while (width-- > 0) {
- *data++ = (byte & mask) ? f->fg : f->bg;
-
- if ((mask >>= 1) == 0)
- mask = 128;
- }
+ while (width-- > 0) {
+ *data++ = (byte & mask) ? f->fg : f->bg;
+
+ if ((mask >>= 1) == 0)
+ mask = 128;
}
}
=back
*/
static void fill_hatchf(i_fill_t *fill, int x, int y, int width, int channels,
- i_fcolor *data, i_fcolor *work) {
+ i_fcolor *data) {
i_fill_hatch_t *f = (i_fill_hatch_t *)fill;
int byte = f->hatch[(y + f->dy) & 7];
int xpos = (x + f->dx) & 7;
int mask = 128 >> xpos;
- if (fill->combinef) {
- int count = width;
- i_fcolor *wstart = work;
-
- while (count-- > 0) {
- *work++ = (byte & mask) ? f->ffg : f->fbg;
-
- if ((mask >>= 1) == 0)
- mask = 128;
- }
- (fill->combinef)(data, wstart, channels, width);
- }
- else {
- while (width-- > 0) {
- *data++ = (byte & mask) ? f->ffg : f->fbg;
-
- if ((mask >>= 1) == 0)
- mask = 128;
- }
+ while (width-- > 0) {
+ *data++ = (byte & mask) ? f->ffg : f->fbg;
+
+ if ((mask >>= 1) == 0)
+ mask = 128;
}
}
=cut
*/
static void fill_image(i_fill_t *fill, int x, int y, int width, int channels,
- i_color *data, i_color *work) {
+ i_color *data) {
struct i_fill_image_t *f = (struct i_fill_image_t *)fill;
- i_color *out = fill->combine ? work : data;
int i = 0;
- i_color c;
+ i_color *out = data;
if (f->has_matrix) {
/* the hard way */
++i;
}
}
-
- if (fill->combine) {
- (fill->combine)(data, work, channels, width);
+ if (f->src->channels == 3) {
+ /* just set the alpha */
+ for (i = 0; i < width; ++i) {
+ data->channel[3] = 255;
+ data++;
+ }
+ }
+ else if (f->src->channels == 2) {
+ /* copy the alpha to channel 3, duplicate the grey value */
+ for (i = 0; i < width; ++i) {
+ data->channel[3] = data->channel[1];
+ data->channel[1] = data->channel[2] = data->channel[0];
+ data++;
+ }
+ }
+ else if (f->src->channels == 1) {
+ /* set the alpha, duplicate grey */
+ for (i = 0; i < width; ++i) {
+ data->channel[3] = 255;
+ data->channel[1] = data->channel[2] = data->channel[0];
+ data++;
+ }
}
}
=cut
*/
static void fill_imagef(i_fill_t *fill, int x, int y, int width, int channels,
- i_fcolor *data, i_fcolor *work) {
+ i_fcolor *data) {
struct i_fill_image_t *f = (struct i_fill_image_t *)fill;
- i_fcolor *out = fill->combine ? work : data;
int i = 0;
- i_fcolor c;
if (f->has_matrix) {
/* the hard way */
}
c2[dy] = interp_i_fcolor(c[dy][0], c[dy][1], rx, f->src->channels);
}
- *out++ = interp_i_fcolor(c2[0], c2[1], ry, f->src->channels);
+ *data++ = interp_i_fcolor(c2[0], c2[1], ry, f->src->channels);
++i;
}
}
}
rx -= ix * f->src->xsize;
ry -= iy * f->src->ysize;
- i_gpixf(f->src, rx, ry, out);
- ++out;
+ i_gpixf(f->src, rx, ry, data);
+ ++data;
++i;
}
}
-
- if (fill->combinef) {
- (fill->combinef)(data, work, channels, width);
+ if (f->src->channels == 3) {
+ /* just set the alpha */
+ for (i = 0; i < width; ++i) {
+ data->channel[3] = 1.0;
+ data++;
+ }
+ }
+ else if (f->src->channels == 2) {
+ /* copy the alpha to channel 3, duplicate the grey value */
+ for (i = 0; i < width; ++i) {
+ data->channel[3] = data->channel[1];
+ data->channel[1] = data->channel[2] = data->channel[0];
+ data++;
+ }
+ }
+ else if (f->src->channels == 1) {
+ /* set the alpha, duplicate grey */
+ for (i = 0; i < width; ++i) {
+ data->channel[3] = 1.0;
+ data->channel[1] = data->channel[2] = data->channel[0];
+ data++;
+ }
}
}
static void combine_color(i_color *, i_color *, int, int);
static void combine_colorf(i_fcolor *, i_fcolor *, int, int);
-struct i_combines {
+static struct i_combines {
i_fill_combine_f combine;
i_fill_combinef_f combinef;
} combines[] =
int ch;
while (count--) {
- i_color c = *in;
double mult[MAXCHANNELS];
mult[3] = in->channel[3];
for (ch = 0; ch < (channels); ++ch) {
}
static void combine_dissolve(i_color *out, i_color *in, int channels, int count) {
- int ch;
-
while (count--) {
if (in->channel[3] > rand() * (255.0 / RAND_MAX))
COMBINE(*out, *in, channels);
}
static void combine_dissolvef(i_fcolor *out, i_fcolor *in, int channels, int count) {
- int ch;
-
while (count--) {
if (in->channel[3] > rand() * (1.0 / RAND_MAX))
COMBINEF(*out, *in, channels);