PHP Classes

Colors in PHP

Recommend this page to a friend!

      Color  >  All threads  >  Colors in PHP  >  (Un) Subscribe thread alerts  
Subject:Colors in PHP
Summary:Color support in PHP: Urgent Help Needed
Messages:3
Author:Arjumand Younus
Date:2007-10-18 06:17:19
Update:2007-10-18 13:38:52
 

  1. Colors in PHP   Reply   Report abuse  
Picture of Arjumand Younus Arjumand Younus - 2007-10-18 06:17:19
Does PHP only support 256 colors...............is there not any way in which PHP can allow more than 256 colors to be displayed in the browser window.I want support of upto a million colors.......plzz reply quickly.

  2. Re: Colors in PHP   Reply   Report abuse  
Picture of Steffen Mueller Steffen Mueller - 2007-10-18 11:28:22 - In reply to message 1 from Arjumand Younus
PHP and the number of colours used by the browser is absolutely totally unrelated. Nothing in common.

The number of colours is controlled by the machine the browser runs on and cannot be controlled by the webpage displayed in the browser. The images the website (aka your php script) sends can contain as many colours as you want, as long as the image is in a format the browser understands. if the browser does not support the million colours you want to display, it will try to match as close as possible.

Again, the question is nonsense. PHP and the displayed number of colours is totally unrelated.

  3. Re: Colors in PHP   Reply   Report abuse  
Picture of Arjumand Younus Arjumand Younus - 2007-10-18 13:38:52 - In reply to message 2 from Steffen Mueller
I am using GD2 which comes with Easy-PHP 1.8.I am reading a bitmap pixel by pixel and displaying it on the browser window.For bitmaps that have 256 colors or less it is working fine but as soon as I reach the 257th color that 257th color is not displayed properly rather it is some approximaetd value.

Check out the following code.......the first should be a series of blue lines and second should be series of green lines.
<?php
//draw1.php
Header("Content-type: image/jpeg");
$image = ImageCreate(500,400);
$gray = ImageColorAllocate($image,204,204,204);
for($i=0;$i<=255;$i++)
{
$blue = ImageColorAllocate($image,0,0,$i);
ImageLine($image,0,$i*2,150,$i*2,$blue);
}
for($j=0;$j<=255;$j++)
{
$green = ImageColorAllocate($image,$j,0,0);
ImageLine($image,175,$j*2,350,$j*2,$green);
}

ImageJPEG($image);
ImageDestroy($image);
?>

Hence the question is not nonsense...........tell me how to resolve this problem.