imageColorAllocate problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi phpers,

I'm having a strange problem. My goal is to be able to generate navigation buttons on the fly. I had this working -- I could pass variable text, size and font information to the php page that generates the image and all worked as expected--png files were created, stored and displayed on the page.

The only issue was that during the testing phase, I had hard coded the color of the button and the text.

	$im = imagecreate (168, $height);	
	$buttoncolor1 = imageColorAllocate ($im, 51, 51, 51);
   	$navtextcolor1 = ImageColorAllocate ($im, 153, 153, 153);
  	
$x = 160-$width;
ImageTTFText ($im, $textsize, 0, $x, 20, $navtextcolor1, $font, $name);
$handle = fopen ($filename, "w");
ImagePNG($im, $filename);

imagePNG($im);

imagedestroy($im);

This gave me a light gray button with dark gray text.

The next step was to be able to pass the button and text colors to the php page, as well.

	$im = imagecreate (168, $height);	
	$buttoncolor1 = imageColorAllocate ($im, $redb, $greenb, $blueb);
   	$navtextcolor1 = ImageColorAllocate ($im, $redt, $greent, $bluet);
				
$x = 160-$width;
ImageTTFText ($im, $textsize, 0, $x, 20, $navtextcolor1, $font, $name);
$handle = fopen ($filename, "w");
ImagePNG($im, $filename);

imagePNG($im);

imagedestroy($im);
}

The only thing that changed was to use variables in the imageColorAllocate function instead of entering actual numbers (I also added code to GET the color variables).

I no longer got any buttons -- just a series of question marks.

In case the problem was with the passing of the color numbers, I added the following lines just before the imagecreate function as a test:

		$redt = 51;
		$greent = 51;
		$bluet = 51;
			
		$redb = 153;
		$greenb = 153;
		$blueb = 153;

That did not help.

The kicker is that the png images are being generated -- i find them in the folder where they are saved. But they do not appear on the page. When the color numbers are hardcoded they do appear.

Thanks for any help you can give with this.

Jo Ann
Jo Ann Comito
by Design
Complete Design & Production Services
For Print and Web
www.greatbydesign.com/



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux