]> git.imager.perl.org - imager.git/blobdiff - filters.im
correct synopsis
[imager.git] / filters.im
index d76a8b115c6d7edc9074f411c615d519639fb430..9ebb0af74795acd51b7b1a2b95991a08f6ffcc95 100644 (file)
@@ -14,8 +14,9 @@ filters.im - implements filters that operate on images
   
   i_contrast(im, 0.8);
   i_hardinvert(im);
+  i_hardinvertall(im);
   i_unsharp_mask(im, 2.0, 1.0);
-  // and more
+  ... and more
 
 =head1 DESCRIPTION
 
@@ -94,21 +95,11 @@ i_contrast(i_img *im, float intensity) {
 }
 
 
-/* 
-=item i_hardinvert(im)
-
-Inverts the pixel values of the input image.
-
-  im        - image object
-
-=cut
-*/
-
-void
-i_hardinvert(i_img *im) {
+static int
+s_hardinvert_low(i_img *im, int all) {
   int x, y;
   int ch;
-  int color_channels = i_img_color_channels(im);
+  int invert_channels = all ? im->channels : i_img_color_channels(im);
 
   mm_log((1,"i_hardinvert(im %p)\n", im));
   
@@ -122,7 +113,7 @@ i_hardinvert(i_img *im) {
     IM_GLIN(im, 0, im->xsize, y, row);
     entry = row;
     for(x = 0; x < im->xsize; x++) {
-      for(ch = 0; ch < color_channels; ch++) {
+      for(ch = 0; ch < invert_channels; ch++) {
        entry->channel[ch] = IM_SAMPLE_MAX - entry->channel[ch];
       }
       ++entry;
@@ -131,9 +122,39 @@ i_hardinvert(i_img *im) {
   }  
   myfree(row);
 #/code
+
+  return 1;
 }
 
+/* 
+=item i_hardinvert(im)
+
+Inverts the color channels of the input image.
 
+  im        - image object
+
+=cut
+*/
+
+void
+i_hardinvert(i_img *im) {
+  s_hardinvert_low(im, 0);
+}
+
+/* 
+=item i_hardinvertall(im)
+
+Inverts all channels of the input image.
+
+  im        - image object
+
+=cut
+*/
+
+void
+i_hardinvertall(i_img *im) {
+  s_hardinvert_low(im, 1);
+}
 
 /*
 =item i_noise(im, amount, type)
@@ -1708,13 +1729,24 @@ typedef struct {
 } i_fill_fountain_t;
 
 static void
-fill_fountf(i_fill_t *fill, int x, int y, int width, int channels, 
+fill_fountf(i_fill_t *fill, i_img_dim x, i_img_dim y, i_img_dim width, int channels, 
             i_fcolor *data);
 static void
 fount_fill_destroy(i_fill_t *fill);
 
+static i_fill_fountain_t
+fount_fill_proto =
+  {
+    {
+      NULL,
+      fill_fountf,
+      fount_fill_destroy
+    }
+  };
+
+
 /*
-=item i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, count, segs)
+=item i_new_fill_fount(C<xa>, C<ya>, C<xb>, C<yb>, C<type>, C<repeat>, C<combine>, C<super_sample>, C<ssample_param>, C<count>, C<segs>)
 
 =category Fills
 =synopsis fill = i_new_fill_fount(0, 0, 100, 100, i_ft_linear, i_ft_linear, 
@@ -1733,9 +1765,7 @@ i_new_fill_fount(double xa, double ya, double xb, double yb,
                  int count, i_fountain_seg *segs) {
   i_fill_fountain_t *fill = mymalloc(sizeof(i_fill_fountain_t));
   
-  fill->base.fill_with_color = NULL;
-  fill->base.fill_with_fcolor = fill_fountf;
-  fill->base.destroy = fount_fill_destroy;
+  *fill = fount_fill_proto;
   if (combine)
     i_get_combine(combine, &fill->base.combine, &fill->base.combinef);
   else {
@@ -2337,8 +2367,8 @@ The fill function for fountain fills.
 =cut
 */
 static void
-fill_fountf(i_fill_t *fill, int x, int y, int width, int channels, 
-            i_fcolor *data) {
+fill_fountf(i_fill_t *fill, i_img_dim x, i_img_dim y, i_img_dim width,
+           int channels, i_fcolor *data) {
   i_fill_fountain_t *f = (i_fill_fountain_t *)fill;
   
   while (width--) {