Re: [PHP] imagecolorallocate / imagesetpixel / palette size?

2001-02-12 Thread Matt McClanahan

On Sun, Feb 11, 2001 at 01:40:11AM -0700, Dan Harrington wrote:

(snip)

 Its like the "palette" only holds 256 pixels or something, what's
 the deal with that?
 
 Anyone experienced this before?  I've looked through the GD library
 documentation
 at boutell.com, i've looked through php.net, and every search engine on the
 internet, and I can't seem to find out what is going on.

You're right, the palette only holds 256 colors.  The reason for this
is that GD was originally written for GIFs only.  JPEGs were added on
later, and then PNGs were put in as a drop-in replacement for GIFs
(Patent issues).  But the library was never extended to support high
color.

If you're using Unix, one alternative could be php_imlib.

http://mmcc.cx/php_imlib/

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] imagecolorallocate / imagesetpixel / palette size?

2001-02-12 Thread Dan Harrington

You are kidding me, right?
I can't believe it.  In this age, 256 colors just doesn't cut the mustard.
Oh well, free is free, ya get what ya pay for.
And here I was all excited about the GD library.

Thanks
Dan


-Original Message-
From: Matt McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 12, 2001 10:16 AM
To: Dan Harrington
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] imagecolorallocate / imagesetpixel / palette size?


On Sun, Feb 11, 2001 at 01:40:11AM -0700, Dan Harrington wrote:

(snip)

 Its like the "palette" only holds 256 pixels or something, what's
 the deal with that?

 Anyone experienced this before?  I've looked through the GD library
 documentation
 at boutell.com, i've looked through php.net, and every search engine on
the
 internet, and I can't seem to find out what is going on.

You're right, the palette only holds 256 colors.  The reason for this
is that GD was originally written for GIFs only.  JPEGs were added on
later, and then PNGs were put in as a drop-in replacement for GIFs
(Patent issues).  But the library was never extended to support high
color.

If you're using Unix, one alternative could be php_imlib.

http://mmcc.cx/php_imlib/

Matt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] imagecolorallocate / imagesetpixel / palette size?

2001-02-12 Thread Brian V Bonini

That's because it was originally designed for gif's.
Gif's only have a 256 color palette..

 -Original Message-
 From: Dan Harrington [mailto:[EMAIL PROTECTED]]
 Sent: Monday, February 12, 2001 12:30 PM
 To: Matt McClanahan
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP] imagecolorallocate / imagesetpixel / palette size?


 You are kidding me, right?
 I can't believe it.  In this age, 256 colors just doesn't cut the mustard.
 Oh well, free is free, ya get what ya pay for.
 And here I was all excited about the GD library.

 Thanks
 Dan




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] imagecolorallocate / imagesetpixel / palette size?

2001-02-11 Thread Dan Harrington

Here is something weird going on.  Why is it that imagecolorallocate dies
after 256 colors have been allocated?  Note, this doesn't matter if
you write a jpg or png, it all produces the same result (see attached
graphic).

Yes, the colors are randomly made, and they all go in a straight, diagonal
line (315 degrees to be precise), and on the 256'th pixel
(I HAVE COUNTED EVERY PIXEL TO MAKE SURE)
it gets stuck on the last color and then continues painting pixels at that
last color until the end of the line.

I've tried to use imagecolordeallocate right after the pixel is drawn,
but that only makes all the pixels come out in one color (white).

Its like the "palette" only holds 256 pixels or something, what's
the deal with that?

Anyone experienced this before?  I've looked through the GD library
documentation
at boutell.com, i've looked through php.net, and every search engine on the
internet, and I can't seem to find out what is going on.

Thanks
Dan

==
?
$im = imagecreate(400,400);

//sets background to black
imagecolorallocate($im,0,0,0);

$x=0;
$y=0;

while ($x =400 ){
$color=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im,$x,$y,$color);
++$x;
++$y;
}

header("Content-type: image/png");
Imagepng($im);
ImageDestroy($im);
?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]