-#include "image.h"
-#include "imagei.h"
+#include "imager.h"
+#include "imageri.h"
#include <stdlib.h>
#include <math.h>
int x, y;
unsigned char ch;
- i_color rcolor;
+ i_color *row, *entry;
- mm_log((1,"i_hardinvert(im %p)\n", im));
+ mm_log((1,"i_hardinvert(im %p)\n", im));
+
+ row = mymalloc(sizeof(i_color) * im->xsize);
for(y = 0; y < im->ysize; y++) {
+ i_glin(im, 0, im->xsize, y, row);
+ entry = row;
for(x = 0; x < im->xsize; x++) {
- i_gpix(im, x, y, &rcolor);
-
for(ch = 0; ch < im->channels; ch++) {
- rcolor.channel[ch] = 255 - rcolor.channel[ch];
+ entry->channel[ch] = 255 - entry->channel[ch];
}
-
- i_ppix(im, x, y, &rcolor);
+ ++entry;
}
+ i_plin(im, 0, im->xsize, y, row);
}
+ myfree(row);
}
=cut
*/
-#ifdef _MSC_VER
+#ifdef WIN32
/* random() is non-ASCII, even if it is better than rand() */
#define random() rand()
#endif
int vx, vy, ch;
i_color val, wval;
- for(vx=0;vx<128;vx++) for(vy=0;vy<110;vy++) {
+ int mx = wmark->xsize;
+ int my = wmark->ysize;
+
+ for(vx=0;vx<mx;vx++) for(vy=0;vy<my;vy++) {
i_gpix(im, tx+vx, ty+vy,&val );
i_gpix(wmark, vx, vy, &wval);
int channels = im->channels;
int xsize = im->xsize;
int ysize = im->ysize;
+ int bytes;
float *fdist;
ICL_info(&ival[p]);
}
- fdist = mymalloc( sizeof(float) * num );
+ /* on the systems I have sizeof(float) == sizeof(int) and thus
+ this would be same size as the arrays xo and yo point at, but this
+ may not be true for other systems
+
+ since the arrays here are caller controlled, I assume that on
+ overflow is a programming error rather than an end-user error, so
+ calling exit() is justified.
+ */
+ bytes = sizeof(float) * num;
+ if (bytes / num != sizeof(float)) {
+ fprintf(stderr, "integer overflow calculating memory allocation");
+ exit(1);
+ }
+ fdist = mymalloc( bytes ); /* checked 14jul05 tonyc */
for(y = 0; y<ysize; y++) for(x = 0; x<xsize; x++) {
float cs = 0;
}
}
+/*
+=item i_nearest_color(im, num, xo, yo, oval, dmeasure)
+
+This wasn't document - quoth Addi:
+
+ An arty type of filter
+
+FIXME: check IRC logs for actual text.
+
+Inputs:
+
+=over
+
+=item *
+
+i_img *im - image to render on.
+
+=item *
+
+int num - number of points/colors in xo, yo, oval
+
+=item *
+
+int *xo - array of I<num> x positions
+
+=item *
+
+int *yo - array of I<num> y positions
+
+=item *
+
+i_color *oval - array of I<num> colors
+
+xo, yo, oval correspond to each other, the point xo[i], yo[i] has a
+color something like oval[i], at least closer to that color than other
+points.
+
+=item *
+
+int dmeasure - how we measure the distance from some point P(x,y) to
+any (xo[i], yo[i]).
+
+Valid values are:
+
+=over
+
+=item 0
+
+euclidean distance: sqrt((x2-x1)**2 + (y2-y1)**2)
+
+=item 1
+
+square of euclidean distance: ((x2-x1)**2 + (y2-y1)**2)
+
+=item 2
+
+manhattan distance: max((y2-y1)**2, (x2-x1)**2)
+
+=back
+
+An invalid value causes an error exit (the program is aborted).
+
+=back
+
+=cut
+ */
void
i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *oval, int dmeasure) {
i_color *ival;
int ysize = im->ysize;
int *cmatch;
- mm_log((1,"i_nearest_color(im %p, num %d, xo %p, yo %p, ival %p, dmeasure %d)\n", im, num, xo, yo, oval, dmeasure));
+ mm_log((1,"i_nearest_color(im %p, num %d, xo %p, yo %p, oval %p, dmeasure %d)\n", im, num, xo, yo, oval, dmeasure));
tval = mymalloc( sizeof(float)*num*im->channels );
ival = mymalloc( sizeof(i_color)*num );
c1 = 1.0-c2;
for(ch = 0; ch<im->channels; ch++)
- tval[midx*im->channels + ch] = c1*tval[midx*im->channels + ch] + c2 * (float) val.channel[ch];
+ tval[midx*im->channels + ch] =
+ c1*tval[midx*im->channels + ch] + c2 * (float) val.channel[ch];
-
}
- for(p = 0; p<num; p++) for(ch = 0; ch<im->channels; ch++) ival[p].channel[ch] = tval[p*im->channels + ch];
+ for(p = 0; p<num; p++) for(ch = 0; ch<im->channels; ch++)
+ ival[p].channel[ch] = tval[p*im->channels + ch];
i_nearest_color_foo(im, num, xo, yo, ival, dmeasure);
}
=cut
*/
void i_unsharp_mask(i_img *im, double stddev, double scale) {
- i_img copy;
+ i_img *copy;
int x, y, ch;
if (scale < 0)
if (scale > 100)
scale = 100;
- i_copy(©, im);
- i_gaussian(©, stddev);
+ copy = i_copy(im);
+ i_gaussian(copy, stddev);
if (im->bits == i_8_bits) {
i_color *blur = mymalloc(im->xsize * sizeof(i_color) * 2);
i_color *out = blur + im->xsize;
for (y = 0; y < im->ysize; ++y) {
- i_glin(©, 0, copy.xsize, y, blur);
+ i_glin(copy, 0, copy->xsize, y, blur);
i_glin(im, 0, im->xsize, y, out);
for (x = 0; x < im->xsize; ++x) {
for (ch = 0; ch < im->channels; ++ch) {
i_fcolor *out = blur + im->xsize;
for (y = 0; y < im->ysize; ++y) {
- i_glinf(©, 0, copy.xsize, y, blur);
+ i_glinf(copy, 0, copy->xsize, y, blur);
i_glinf(im, 0, im->xsize, y, out);
for (x = 0; x < im->xsize; ++x) {
for (ch = 0; ch < im->channels; ++ch) {
myfree(blur);
}
- i_img_exorcise(©);
+ i_img_destroy(copy);
}
/*
i_img *out;
int outchans, diffchans;
int xsize, ysize;
- i_img temp;
i_clear_error();
if (im1->channels != im2->channels) {
fount_fill_destroy(i_fill_t *fill);
/*
-=item i_new_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs)
+=item i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs)
+
+=category Fills
+=synopsis fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear,
+=synopsis i_fr_triangle, 0, i_fts_grid, 9, 1, segs);
+
Creates a new general fill which fills with a fountain fill.