Hi;
I am sending an array of coordinates to a script that will generate a jpeg image. The code to generate the image is:
<?php
$xuser = $GET["xuser"];
$yuser = $GET["yuser"];
$foilist = unserialize(stripslashes($_GET["foi"]));
$num_foi = count($foilist);
$xo = 390000;
$yo = 669454;
$xpix = 12;
$ypix = 11;
$x[0] = ceil(($xuser - $xo)/$xpix);
$y[0] = ceil(($yo - $yuser)/$ypix);
for ($i=0;$i<$num_foi;$i++) {
$x[$i+1] = ceil(($foilist[$i][1] - $xo)/$xpix);
$y[$i+1] = ceil(($yo - $foilist[$i][2])/$ypix);
}
Header("Content-type: image/jpeg");
$image = ImageCreateFromJPEG("../images/stabbs.jpg");
$red = ImageColorAllocate($image,255,0,0);
$green = ImageColorAllocate($image,0,255,0);
$blue = ImageColorAllocate($image,0,0,255);
for ($i=0;$i<$num_foi+1;$i++) {
if ($i == 0) ImageFilledRectangle($image,$x[0],$y[0],$x[0]+5,$y[0]+5,$red);
else ImageFilledRectangle($image,$x[$i],$y[$i],$x[$i]+5,$y[$i]+5,$green);
}
ImageJPEG($image);
ImageDestroy($image);
?>
When computed the x and y array contains the following values, which I can echo to screen:
$x = [128,174,113] and $y=[86,189,185]
The image size is 200x216, so all the points are in the image.
The above code generates a single red rectangle on the screen, but no green rectangles. However, if I hard code the coordinates into the $x and $y arrays I get one red and two green rectangles!
I am struggling to know what is going on here, so wonder whether anyone can offer some insight.
Thanks
Fraser