note 70764 added to function.imagerotate
| From: | orthello at ronsoft dot nl | Date: | Fri, 27 Oct 2006 00:00:52 +0000 |
| Subject: | note 70764 added to function.imagerotate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119154@lists.php.net to get a copy of this message | ||
Dear all.
There is still something going on with the bgd_color part of the parameters.
I created an image with a white background. During rotation bgd_color is set to 0 (zero)
When rotating the image more then 45 degrees but less then 316 (360-45) degrees, the color of the
uncovered zone becomes unpredictable. It looks like the color is part of the palet though.
Also when the angle is negative, or exeeds 360, the behaviour is simular.
So if angle is -675 to -405 it goos wrong when bgd_color == 0;
So if angle is -315 to -45 it goos wrong when bgd_color == 0;
So if angle is 45 to 315 it goos wrong when bgd_color == 0;
So if angle is 405 to 675 it goos wrong when bgd_color == 0;
and so on, and so on....
As allready written by barbarism it helps when bgd_color is set to -1
But in fact the 'problem' gets inverted in that way. Because when bgd_color is set to -1
and the angle is -45 to 45 degrees, the same problem occurs.
This behaviour is experienced on:
Windows XP home (fully patched)
Apache/2.0.55 (Win32) PHP/5.1.2
GD bundled (2.0.28 compatible)
The behaviour is NOT experienced on (as in bgd_color can remain 0 for all angles):
Linux (kernl 2.4.21-47)
Apache/2.0.55 PHP/4.4.2
GD bundled (2.0.28 compatible)
So it looks like this behaviour can be found in PHP5.
needle.php (http://www.ronsoft.nl/geotools/compass.php)
<?
header("Content-type: image/gif");
$img = imagecreate(200, 200);
$bg = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 181, 4, 4);
$white = imagecolorallocate($img, 255, 255, 255);
$blue = imagecolorallocate($img, 197, 223, 223);
// draw big circle
imagefilledellipse($img, 100, 100, 200, 200, $blue);
//draw arrow
$values = array(
0, 0, // Point 1 (x, y)
145, 55, // Point 2 (x, y)
55, 145, // Point 3 (x, y)
);
imagefilledpolygon($img, $values, 3, $red);
// draw small circle
imagefilledellipse($img, 100, 100, 50, 50, $white);
$img2 = imagecreate(283, 283); //size depents on 45 degree measurments of needle
$white2 = imagecolorallocate($img2, 255, 255, 255);
// put angle in clockwise direction
$ang = 360-intval(substr($_SERVER["PATH_INFO"], 1));
// work around bgd_color issue for imagerotate
if ($ang > 45 && $ang < 316) $bgd = -1;
else $bgd = 0;
// rotate image
$img = imagerotate($img, $ang, $bgd);
// check size of new image and calculate border sizes (45 degrees)
$srcw = imagesx($img);
$srch = imagesy($img);
$rx = imagesx($img2);
$ry = imagesy($img2);
$dstx = ($rx - $srcw)/2;
$dsty = ($ry - $srch)/2;
// put needle on background
imagecopymerge($img2, $img, $dstx, $dsty, 0, 0, $srcw, $srch, 100);
imagecolortransparent($img2, $white2);
imagegif($img2);
?>
----
Server IP: 194.109.193.119
Probable Submitter: 84.87.111.110
----
Manual Page -- http://www.php.net/manual/en/function.imagerotate.php
Edit -- https://master.php.net/note/edit/70764
Del: integrated -- https://master.php.net/note/delete/70764/integrated
Del: useless -- https://master.php.net/note/delete/70764/useless
Del: bad code -- https://master.php.net/note/delete/70764/bad+code
Del: spam -- https://master.php.net/note/delete/70764/spam
Del: non-english -- https://master.php.net/note/delete/70764/non-english
Del: in docs -- https://master.php.net/note/delete/70764/in+docs
Del: other reasons-- https://master.php.net/note/delete/70764
Reject -- https://master.php.net/note/reject/70764
Search -- https://master.php.net/manage/user-notes.php