Re: Trying to create a colortable - what am I missing here?

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

 



דניאל דנון wrote:
I've tried to make a color table, but I am missing something. not in the
color-table-code itself, but in somewhere else... I just can't find...

untested but try..

// 4096*4096 = 16777216 = FFFFFF+1
$im = imagecreate(4096, 4096);
$white = imagecolorallocate($im, 0, 0, 0);
$r = $g = $b = $x = $y =  0;
$max = 255;
while ($r <= $max) {
  while ($g <= $max) {
    while ($b <= $max) {
      $n = imagecolorallocate($im, $r, $g, $b);
      imagesetpixel($im, $x, $y, $n);
      $x = $x == 4096 ? 0 : $x+1;
      $y = $y == 4096 ? 0 : $y+1;
      $b++;
    }
   $b = 0;
   $g++;
  }
  $g = 0;
  $r++;
}
header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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