Skip to content

Commit c9a67b1

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: - fix name for imageflip constants, consistent witht the other - add test - add constants for imageflip
2 parents 6192dba + 74983a4 commit c9a67b1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

ext/gd/gd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,10 @@ PHP_MINIT_FUNCTION(gd)
12001200
REGISTER_LONG_CONSTANT("IMG_EFFECT_NORMAL", gdEffectNormal, CONST_CS | CONST_PERSISTENT);
12011201
REGISTER_LONG_CONSTANT("IMG_EFFECT_OVERLAY", gdEffectOverlay, CONST_CS | CONST_PERSISTENT);
12021202
REGISTER_LONG_CONSTANT("GD_BUNDLED", 1, CONST_CS | CONST_PERSISTENT);
1203+
1204+
REGISTER_LONG_CONSTANT("IMG_FLIP_HORINZONTAL", GD_FLIP_HORINZONTAL, CONST_CS | CONST_PERSISTENT);
1205+
REGISTER_LONG_CONSTANT("IMG_FLIP_VERTICAL", GD_FLIP_VERTICAL, CONST_CS | CONST_PERSISTENT);
1206+
REGISTER_LONG_CONSTANT("IMG_FLIP_BOTH", GD_FLIP_BOTH, CONST_CS | CONST_PERSISTENT);
12031207
#else
12041208
REGISTER_LONG_CONSTANT("GD_BUNDLED", 0, CONST_CS | CONST_PERSISTENT);
12051209
#endif

ext/gd/tests/imageflip.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Testing imageflip() of GD library
3+
--SKIPIF--
4+
<?php
5+
if ( ! extension_loaded('gd') || !function_exists('imageflip')) die( 'skip GD not present; skipping test' );
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$im = imagecreatetruecolor( 99, 99 );
11+
12+
imagesetpixel($im, 0, 0, 0xFF);
13+
imagesetpixel($im, 0, 98, 0x00FF00);
14+
imagesetpixel($im, 98, 0, 0xFF0000);
15+
imagesetpixel($im, 98, 98, 0x0000FF);
16+
17+
imageflip($im, IMG_FLIP_HORINZONTAL);
18+
imageflip($im, IMG_FLIP_VERTICAL);
19+
imageflip($im, IMG_FLIP_BOTH);
20+
21+
22+
var_dump(dechex(imagecolorat($im, 0, 0)));
23+
var_dump(dechex(imagecolorat($im, 0, 98)));
24+
var_dump(dechex(imagecolorat($im, 98, 0)));
25+
var_dump(dechex(imagecolorat($im, 98, 98)));
26+
?>
27+
--EXPECT--
28+
string(2) "ff"
29+
string(4) "ff00"
30+
string(6) "ff0000"
31+
string(2) "ff"

0 commit comments

Comments
 (0)