imagecreatefromjpeg: additions not dipsplaying proper color
Posted: Mon Dec 27, 2004 9:01 pm
php version: 4.2.2
GD Version: 1.6.2 or higher //I dunno what it means by that, that's just what phpinfo() tells me.
image of which I speak: http://www.ohioamtgard.com/map_code.php
purpose: get a list of amtgard groups in Ohio and display a block over the location of each (the location being determined by zip/lat&long db comparing to the zip of the group) on the map.
It looks like it's using the closest color already existing on the image, but when I added a red splotch to the image, it still displayed the incorrect color.
I get the impression it might have something to do with my GD version, but I've not seen a solution short of loading 2.0 | >, something I don't have the authority to do.
Any help is welcomed
feyd | Help us, help you. Please use
GD Version: 1.6.2 or higher //I dunno what it means by that, that's just what phpinfo() tells me.
image of which I speak: http://www.ohioamtgard.com/map_code.php
purpose: get a list of amtgard groups in Ohio and display a block over the location of each (the location being determined by zip/lat&long db comparing to the zip of the group) on the map.
Code: Select all
<?PHP
require ('CENSORED');
header ("Content-type: image/png");
function getlocationcoords($lat, $lon, $width, $height)
{
$x = (650-(($lon-80.53357) * ($width / 4.25216)));
$y = (707-(($lat-38.465171) * ($height / 3.445505)));
return array("x"=>round($x),"y"=>round($y));
}
// First we load the background/base map.
// We will also allocate the colors for the markers and the text, as well as the font
$im = imagecreatefromjpeg("images/ohio.jpg");
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate ($im, 255,0,0);
$grey = imagecolorallocate ($im, 100,100,100);
$white = imagecolorallocate($im, 255, 255, 255);
$font = '/home/httpd/vhosts/ohioamtgard.com/httpdocs/Braveheart.ttf';
// Next need to find the base image size.
// We need these variables to be able scale the long/lat coordinates.
$scale_x = imagesx($im);
$scale_y = imagesy($im);
$getgroups=mysql_query("SELECT t1.lat, t1.long, t2.name FROM CENSORED as t1, CENSORED as t2 WHERE t1.zip=t2.location", $db) or
die (mysql_error());
while($groups=mysql_fetch_array($getgroups)){
$lat=$groups[0];
$long=(0-$groups[1]);
$text=$groups[2];
settype($lat, "float");
settype($long, "float");
// Now we convert the long/lat coordinates into screen coordinates
$pt = getlocationcoords($lat, $long, $scale_x, $scale_y);
// Now mark the point on the map using a red 40 pixel rectangle
imagefilledrectangle($im,$pt["x"]-20,$pt["y"]-20,$pt["x"]+20,$pt["y"]+20,$red);
// Add some shadow for the text
imagettftext($im, 18, 0, $pt["x"]+1, $pt["y"]+1, $grey, $font, $text);
// Add the text
imagettftext($im, 18, 0, $pt["x"], $pt["y"], $black, $font, $text);
};
// Return the map image.
imagepng($im);
imagedestroy($im);
?>I get the impression it might have something to do with my GD version, but I've not seen a solution short of loading 2.0 | >, something I don't have the authority to do.
Any help is welcomed
feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]