]> git.imager.perl.org - imager.git/blobdiff - paste.im
skip t/x30podlinkcheck.t if Pod::Parser 1.50 not available
[imager.git] / paste.im
index ef7d1445a64d773a4306eed65221d3ae36a26227..8cd2b710058900e59fb57051968db7995db30fc5 100644 (file)
--- a/paste.im
+++ b/paste.im
@@ -1,22 +1,24 @@
 #include "imager.h"
+#include "imageri.h"
 
 /*
-=item i_copyto(dest, src, x1, y1, x2, y2, tx, ty)
+=item i_copyto(C<dest>, C<src>, C<x1>, C<y1>, C<x2>, C<y2>, C<tx>, C<ty>)
 
 =category Image
 
-Copies image data from the area (x1,y1)-[x2,y2] in the source image to
-a rectangle the same size with it's top-left corner at (tx,ty) in the
-destination image.
+Copies image data from the area (C<x1>,C<y1>)-[C<x2>,C<y2>] in the
+source image to a rectangle the same size with it's top-left corner at
+(C<tx>,C<ty>) in the destination image.
 
-If x1 > x2 or y1 > y2 then the corresponding co-ordinates are swapped.
+If C<x1> > C<x2> or C<y1> > C<y2> then the corresponding co-ordinates
+are swapped.
 
 =cut
 */
 
 void
-i_copyto(i_img *im, i_img *src, int x1, int y1, int x2, int y2, int tx, int ty) {
-  int y, t, ttx, tty;
+i_copyto(i_img *im, i_img *src, i_img_dim x1, i_img_dim y1, i_img_dim x2, i_img_dim y2, i_img_dim tx, i_img_dim ty) {
+  i_img_dim y, t, ttx, tty;
   
   if (x2<x1) { t=x1; x1=x2; x2=t; }
   if (y2<y1) { t=y1; y1=y2; y2=t; }
@@ -40,8 +42,9 @@ i_copyto(i_img *im, i_img *src, int x1, int y1, int x2, int y2, int tx, int ty)
   if (x1 == x2 || y1 == y2)
     return; /* nothing to do */
 
-  mm_log((1,"i_copyto(im* %p, src %p, x1 %d, y1 %d, x2 %d, y2 %d, tx %d, ty %d)\n",
-         im, src, x1, y1, x2, y2, tx, ty));
+  mm_log((1,"i_copyto(im* %p, src %p, p1(" i_DFp "), p2(" i_DFp "), t("
+         i_DFp "))\n",
+         im, src, i_DFcp(x1, y1), i_DFcp(x2, y2), i_DFcp(tx, ty)));
 
 #code im->bits == i_8_bits
   IM_COLOR *row = mymalloc(sizeof(IM_COLOR) * (x2-x1));
@@ -58,8 +61,6 @@ i_copyto(i_img *im, i_img *src, int x1, int y1, int x2, int y2, int tx, int ty)
 #/code
 }
 
-#define color_to_grey(col) ((col)->rgb.r * 0.222  + (col)->rgb.g * 0.707 + (col)->rgb.b * 0.071)
-
 #code
 void
 #ifdef IM_EIGHT_BIT
@@ -328,16 +329,27 @@ i_adapt_fcolors_bg
 }
 
 /*
-=item i_gsamp_bg(im, l, r, y, samples, out_channels, bg)
+=item i_gsamp_bg(im, l, r, y, samples, out_channels, background)
+
+=category Drawing
+
+Like C<i_gsampf()> but applies the source image color over a supplied
+background color.
+
+This is intended for output to image formats that don't support alpha
+channels.
+
+=cut
+
+=item i_gsampf_bg(im, l, r, y, samples, out_channels, background)
 
-=item i_gsampf_bg(im, l, r, y, samples, out_channels, bg)
+=category Drawing
 
-This is similar to i_adapt_colors_bg() except it can only strip an
-alpha channel.  It cannot be used to convert a source RGB image to
-greyscale.
+Like C<i_gsampf()> but applies the source image color over a supplied
+background color.
 
-The samples parameter MUST include enough space for all samples of the
-source image.
+This is intended for output to image formats that don't support alpha
+channels.
 
 =cut
 */
@@ -347,7 +359,7 @@ i_gsamp_bg
 #else
 i_gsampf_bg
 #endif
-(i_img *im, int l, int r, int y, IM_SAMPLE_T *samples, 
+(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, IM_SAMPLE_T *samples, 
  int out_channels, IM_COLOR const *bg) {
   if (out_channels == im->channels)
     return IM_GSAMP(im, l, r, y, samples, NULL, im->channels);
@@ -357,10 +369,10 @@ i_gsampf_bg
     switch (im->channels) {
     case 2:
       {
-       int x;
+       i_img_dim x;
        IM_SAMPLE_T *inp = samples, *outp = samples;
        IM_WORK_T grey_bg = IM_ROUND(color_to_grey(bg));
-       int count;
+       i_img_dim count;
 
        count = IM_GSAMP(im, l, r, y, samples, NULL, im->channels);
        if (!count)
@@ -390,9 +402,10 @@ i_gsampf_bg
       }
     case 2:
       {
-       int x, ch;
+       i_img_dim x;
+       int ch;
        IM_SAMPLE_T *inp = samples, *outp = samples;
-       int count;
+       i_img_dim count;
        int channels[4] = { 0, 0, 0, 1 };
 
        count = IM_GSAMP(im, l, r, y, samples, channels, im->channels);
@@ -413,9 +426,10 @@ i_gsampf_bg
 
     case 4:
       {
-       int x, ch;
+       i_img_dim x;
+       int ch;
        IM_SAMPLE_T *inp = samples, *outp = samples;
-       int count;
+       i_img_dim count;
 
        count = IM_GSAMP(im, l, r, y, samples, NULL, im->channels);
        if (!count)