]> git.imager.perl.org - imager.git/blobdiff - filters.c
- limit limits.c to C89
[imager.git] / filters.c
index 04c3926d135422a737c9304615c5538ccc20e779..2523de51932120b8224aecf36ca5797788322b63 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -140,7 +140,7 @@ Inverts the pixel values by the amount specified.
 =cut
 */
 
-#ifdef _MSC_VER
+#ifdef WIN32
 /* random() is non-ASCII, even if it is better than rand() */
 #define random() rand()
 #endif
@@ -649,7 +649,10 @@ i_watermark(i_img *im, i_img *wmark, int tx, int ty, int pixdiff) {
   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);
@@ -1213,7 +1216,6 @@ i_diff_image(i_img *im1, i_img *im2, int mindiff) {
   i_img *out;
   int outchans, diffchans;
   int xsize, ysize;
-  i_img temp;
 
   i_clear_error();
   if (im1->channels != im2->channels) {
@@ -1242,6 +1244,11 @@ i_diff_image(i_img *im1, i_img *im2, int mindiff) {
     for (y = 0; y < ysize; ++y) {
       i_glin(im1, 0, xsize, y, line1);
       i_glin(im2, 0, xsize, y, line2);
+      if (outchans != diffchans) {
+        /* give the output an alpha channel since it doesn't have one */
+        for (x = 0; x < xsize; ++x)
+          line2[x].channel[diffchans] = 255;
+      }
       for (x = 0; x < xsize; ++x) {
         int diff = 0;
         for (ch = 0; ch < diffchans; ++ch) {
@@ -1271,6 +1278,11 @@ i_diff_image(i_img *im1, i_img *im2, int mindiff) {
     for (y = 0; y < ysize; ++y) {
       i_glinf(im1, 0, xsize, y, line1);
       i_glinf(im2, 0, xsize, y, line2);
+      if (outchans != diffchans) {
+        /* give the output an alpha channel since it doesn't have one */
+        for (x = 0; x < xsize; ++x)
+          line2[x].channel[diffchans] = 1.0;
+      }
       for (x = 0; x < xsize; ++x) {
         int diff = 0;
         for (ch = 0; ch < diffchans; ++ch) {