]> git.imager.perl.org - imager.git/blobdiff - conv.im
various changes updates
[imager.git] / conv.im
diff --git a/conv.im b/conv.im
index b7afa6478df078cb648b9f3d55b0228b82f402c6..f02db85633db7824087c8b21d179218143c591d5 100644 (file)
--- a/conv.im
+++ b/conv.im
@@ -6,7 +6,7 @@
   end effects are acounted for by increasing
   scaling the result with the sum of used coefficients
 
-  coeff: (float array) coefficients for filter
+  coeff: (double array) coefficients for filter
     len: length of filter.. number of coefficients
            note that this has to be an odd number
            (since the filter is even);
@@ -14,7 +14,7 @@
 
 int
 i_conv(i_img *im, const double *coeff,int len) {
-  int xo, yo; /* output pixel co-ordinate */
+  i_img_dim xo, yo; /* output pixel co-ordinate */
   int c, ch, center;
   double pc;
   double res[MAXCHANNELS];
@@ -22,6 +22,11 @@ i_conv(i_img *im, const double *coeff,int len) {
 
   mm_log((1,"i_conv(im %p, coeff %p, len %d)\n",im,coeff,len));
   i_clear_error();
+
+  if (len < 1) {
+    i_push_error(0, "there must be at least one coefficient");
+    return 0;
+  }
  
   center=(len-1)/2;
 
@@ -45,7 +50,7 @@ i_conv(i_img *im, const double *coeff,int len) {
       for(ch = 0;ch < im->channels; ch++) 
        res[ch] = 0;
       for(c = 0;c < len; c++) {
-       int xi = xo + c - center;
+       i_img_dim xi = xo + c - center;
        if (xi < 0)
          xi = 0;
        else if (xi >= im->xsize)
@@ -71,7 +76,7 @@ i_conv(i_img *im, const double *coeff,int len) {
       for(ch =  0; ch < im->channels; ch++)
        res[ch] = 0;
       for(c = 0; c < len; c++) {
-       int yi = yo + c - center;
+       i_img_dim yi = yo + c - center;
        if (yi < 0)
          yi = 0;
        else if (yi >= im->ysize)