}
+sub flip {
+ my $self = shift;
+ my %opts = @_;
+ my %xlate = (x=>0, y=>1, xy=>2, yx=>2);
+ my $dir;
+ return () unless defined $opts{'dir'} and defined $xlate{$opts{'dir'}};
+ $dir = $xlate{$opts{'dir'}};
+ return $self if i_flipxy($self->{IMG}, $dir);
+ return ();
+}
+
+
# These two are supported for legacy code only
=head2 Drawing Methods
IMPLEMENTATION MORE OR LESS DONE CHECK THE TESTS
-
DOCUMENTATION OF THIS SECTION OUT OF SYNC
It is possible to draw with graphics primitives onto images. Such
That copies the entire C<$logo> image onto the C<$dest> image so that the
upper left corner of the C<$logo> image is at (40,20).
-=head2 Blending Images
-
-To put an image or a part of an image directly into another it is
-best to call the C<paste()> method on the image you want to add to.
+
+=head2 Flipping images
+
+An inplace horizontal or vertical flip is possible by calling the
+C<flip()> method. If the original is to be preserved it's possible
+to make a copy first.
+
+ $img->flip(dir=>"x"); # horizontal flip
+ $img->flip(dir=>"xy"); # vertical and horizontal flip
+ $nimg = $img->copy->flip(dir=>"y"); # make a copy and flip the copy vertically
+
+
+=head2 Blending Images To put an image or a part of an image directly
+into another it is best to call the C<paste()> method on the image you
+want to add to.
$img->paste(img=>$srcimage,left=>30,top=>50);
#define XAXIS 0
#define YAXIS 1
+#define XYAXIS 2
#define minmax(a,b,i) ( ((a>=i)?a: ( (b<=i)?b:i )) )
Re-new image reference
im - Image pointer
- x - xsize of destination image
- y - ysize of destination image
+ x - xsize of destination image
+ y - ysize of destination image
ch - number of channels
=cut
=cut
*/
+
void
i_rubthru(i_img *im,i_img *src,int tx,int ty) {
i_color pv,orig,dest;
}
}
+
+/*
+=item i_flipxy(im, axis)
+
+Flips the image inplace around the axis specified.
+Returns 0 if parameters are invalid.
+
+ im - Image pointer
+ axis - 0 = x, 1 = y, 2 = both
+
+=cut
+*/
+
+undef_int
+i_flipxy(i_img *im, int direction) {
+ int x, x2, y, y2, xm, ym;
+ int xs = im->xsize;
+ int ys = im->ysize;
+
+ mm_log((1, "i_flipxy(im %p, direction %d)\n", im, direction ));
+
+ if (!im) return 0;
+
+ switch (direction) {
+ case XAXIS: /* Horizontal flip */
+ xm = xs/2;
+ ym = ys;
+ for(y=0; y<ym; y++) {
+ x2 = xs-1;
+ for(x=0; x<xm; x++) {
+ i_color val1, val2;
+ i_gpix(im, x, y, &val1);
+ i_gpix(im, x2, y, &val2);
+ i_ppix(im, x, y, &val2);
+ i_ppix(im, x2, y, &val1);
+ x2--;
+ }
+ }
+ break;
+ case YAXIS:
+ xm = xs;
+ ym = ys/2;
+ y2 = ys-1;
+ for(y=0; y<ym; y++) {
+ for(x=0; x<xm; x++) {
+ i_color val1, val2;
+ i_gpix(im, x, y, &val1);
+ i_gpix(im, x, y2, &val2);
+ i_ppix(im, x, y, &val2);
+ i_ppix(im, x, y2, &val1);
+ }
+ y2--;
+ }
+ break;
+ case XYAXIS:
+ xm = xs/2;
+ ym = ys/2;
+ y2 = ys-1;
+ for(y=0; y<ym; y++) {
+ x2 = xs-1;
+ for(x=0; x<xm; x++) {
+ i_color val1, val2;
+ i_gpix(im, x, y, &val1);
+ i_gpix(im, x2, y2, &val2);
+ i_ppix(im, x, y, &val2);
+ i_ppix(im, x2, y2, &val1);
+
+ i_gpix(im, x2, y, &val1);
+ i_gpix(im, x, y2, &val2);
+ i_ppix(im, x2, y, &val2);
+ i_ppix(im, x, y2, &val1);
+ x2--;
+ }
+ y2--;
+ }
+ break;
+ default:
+ mm_log((1, "i_flipxy: direction is invalid\n" ));
+ return 0;
+ }
+ return 1;
+}
+
+
+
+
+
+static
float
Lanczos(float x) {
float PIx, PIx2;
void i_copy (i_img *im,i_img *src);
void i_rubthru (i_img *im,i_img *src,int tx,int ty);
+undef_int i_flipxy (i_img *im, int direction);
+
+
+
void i_bezier_multi(i_img *im,int l,double *x,double *y,i_color *val);
void i_poly_aa (i_img *im,int l,double *x,double *y,i_color *val);