Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with GD library - Gif files

Status
Not open for further replies.

748323

Programmer
Dec 10, 2004
70
0
0
US
I made another "Map" program, where people can add themselves to the map, and see where everybody lives.


The image doesn't actually overwrite itself everytime. It creates text files containing the needed information, and when view.php is accessed, it loads a blank GIF map, and writes all of the circles/names.

The only problem is, it always writes in white, even though I tell it to write it in black. Why does this happen? Thanks!

I'm assuming this is common bug, but if its not, I'll post parts of my source code.
 
Can you post parts of your code please.
Are you using imagecolorallocate() function to allocate black as a colour in the image?

If it aint broke, redesign it!
 
This is the code I use to grab the coordinates, and the usenames.

Code:
<?

$image = imagecreatefromgif("./map.gif");
$black = imagecolorallocate($image, 255, 255, 255);

foreach(glob("./additions/*.txt") as $file) {
	$rfile = substr($file, 12, -4);
	$pieces = explode("_", $rfile);
	$handle = fopen($file, "r+");
	$name = fread($handle, filesize($file));
	$xc = $pieces[0];
	$yc = $pieces[1];
	imageellipse($image, $xc, $yc, 10, 10, $black);  
	imagestring($image, 1, $xc + 8, $yc - 3, "$name", $black);
}

Header("Content-type: image/gif");
imagegif($image);
imagedestroy($image);


?>
 
It also creates and displays the image, obviously.
 
Ugg.. I changed the imagecolorallocate parameters to 0's from 255's, but it still prints in white.
 
strange..
looks right to me..

maybe it's something with the image you are making the color of?

I dont know if you could have a jpg image and try to allocate colors from that?

Olav Alexander Mjelde
Admin & Webmaster
 
I tried recoding it, but it still wouldn't work. I will try getting the color out of another image when I get home,.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top