cvs: pear /Image_Transform/Driver Cairowrapper.php
[email protected] ("Christian Weiske")
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvscweiske1209461105@cvsserver> |
cweiske Tue Apr 29 09:25:05 2008 UTC
Modified files:
/pear/Image_Transform/Driver Cairowrapper.php
Log:
mirror() and flip() for cairowrapper driver
http://cvs.php.net/viewvc.cgi/pear/Image_Transform/Driver/Cairowrapper.php?r1=1.3&r2=1.4&diff_format=u
Index: pear/Image_Transform/Driver/Cairowrapper.php
diff -u pear/Image_Transform/Driver/Cairowrapper.php:1.3 pear/Image_Transform/Driver/Cairowrapper.php:1.4
--- pear/Image_Transform/Driver/Cairowrapper.php:1.3 Mon Apr 28 21:55:13 2008
+++ pear/Image_Transform/Driver/Cairowrapper.php Tue Apr 29 09:25:05 2008
@@ -18,7 +18,7 @@
* @author Christian Weiske <[email protected]>
* @copyright 2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Cairowrapper.php,v 1.3 2008/04/28 21:55:13 cweiske Exp $
+ * @version CVS: $Id: Cairowrapper.php,v 1.4 2008/04/29 09:25:05 cweiske Exp $
* @link http://pear.php.net/package/Image_Transform
*/
require_once 'Image/Transform.php';
@@ -144,12 +144,10 @@
cairo_scale($outputContext, $xFactor, $yFactor);
- $inputContext = cairo_create($this->surface);
cairo_set_source_surface($outputContext, $this->surface, 0, 0);
cairo_paint($outputContext);
cairo_destroy($outputContext);
- cairo_destroy($inputContext);
cairo_surface_destroy($this->surface);
@@ -211,5 +209,61 @@
$this->surface = null;
}//function free()
+
+
+ /**
+ * Mirrors the image horizontally
+ * Uses an affine transformation matrix to flip the image.
+ *
+ * @return void
+ */
+ function flip()
+ {
+ $outputSurface = cairo_image_surface_create(
+ CAIRO_FORMAT_ARGB32, $this->img_x, $this->img_y
+ );
+ $outputContext = cairo_create($outputSurface);
+ // xx, yx, xy, yy, x0, y0
+ $matrix = cairo_matrix_create(1, 0, 0, -1, 0, $this->img_y);
+
+ cairo_set_matrix($outputContext, $matrix);
+ cairo_set_source_surface($outputContext, $this->surface, 0, 0);
+ cairo_paint($outputContext);
+
+ cairo_destroy($outputContext);
+ cairo_surface_destroy($this->surface);
+
+ $this->surface = $outputSurface;
+ }//function flip()
+
+
+
+ /**
+ * Mirrors the image vertically.
+ * Uses an affine transformation matrix to mirror the image.
+ *
+ * 123 -> 321
+ *
+ * @return void
+ */
+ function mirror()
+ {
+ $outputSurface = cairo_image_surface_create(
+ CAIRO_FORMAT_ARGB32, $this->img_x, $this->img_y
+ );
+ $outputContext = cairo_create($outputSurface);
+ // xx, yx, xy, yy, x0, y0
+ $matrix = cairo_matrix_create(-1, 0, 0, 1, $this->img_x, 0);
+
+ cairo_set_matrix($outputContext, $matrix);
+ cairo_set_source_surface($outputContext, $this->surface, 0, 0);
+ cairo_paint($outputContext);
+
+ cairo_destroy($outputContext);
+ cairo_surface_destroy($this->surface);
+
+ $this->surface = $outputSurface;
+ }//function mirror()
+
}//class Image_Transform_Driver_Cairowrapper extends Image_Transform
?>
\ No newline at end of file