ID:               21668
 User updated by:  [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Bogus
+Status:           Open
-Bug Type:         *Graphics related
+Bug Type:         Documentation problem
 Operating System: Win32 / OSF1
 PHP Version:      4.2.3
 New Comment:

I fail to see how that relates to this problem. The
imagecolorsforindex() function is not behaving unexpectedly: it returns
all 216 colours of the palette! Also, as you can see in my first
comment, both imagecolorclosest() and imagecolorresolve() do recognize
the palette (somewhat): they return a colour index of 215 and 214
respectively, not 0, 1 or 2 (<= no. of used colours). The fact that
they return different values also troubles me.

At best this is a documentation bug. The documentation does not
differentiate between colours actually used in the image, and colours
defined in the embedded palette. As I read it now, the functions
~exact(), ~closest() and ~resolve() should search/walk the palette
(like my code snippet does). However it seems as though they can only
return colours that are used in the image.


Previous Comments:
------------------------------------------------------------------------

[2003-01-15 13:02:43] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The color_index parameter for imagecolorsforindex() can be generated by
imagecolorat(). That function can only fetch the avaliable 3 colors of
the image, hence all other colors cannot be resolved regardless of the
palette.
This works the same way in GD 2.X bundled with PHP as it does with you
GD 1.8.4

------------------------------------------------------------------------

[2003-01-15 12:47:59] [EMAIL PROTECTED]

The image does indeed only contain (display) the 3 colours you mention.
The embedded palette however definitly defines 216 colours, as shown by
the output of test.php or:
for ( $i = 0; $i < imagecolorstotal( $im ); ++$i )
{
  $c = imagecolorsforindex( $im, $i );
  echo "$i = {$c['red']} {$c['green']} {$c['blue']}\n";
}
Corel Photopaint also shows me a 216-colour palette.

------------------------------------------------------------------------

[2003-01-15 12:34:09] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

According to my tests that image only contains 3 colors:
255,255,255 
0, 0, 0
204, 204, 204

There is definately no 0,0,153 color.

------------------------------------------------------------------------

[2003-01-15 11:49:31] [EMAIL PROTECTED]

I created an 8-bit paletted png image using PHP, allocating the
complete webpalet 51*(r,g,b) with r,g,b in [0,5]. See
http://www.phys.uu.nl/~varsity/rowperfect/
- env.php only contains phpinfo().
- grid.php creates "grid.png" in the png subdir.
- test.php tries to analyze the colour palette.
As you can see the colour (0,0,153) definitely exists in the palette
and has index number 212. However, when searching for this colour
imagecolorexact() does not return a valid index value (-1) and
imagecolorclosest() returns the highest index number (215) which is
black (0,0,0). Even worse is imagecolorresolve(): it evidently picks
another index (214) and just replaces the existing colour at that
position with (0,0,153).

The behaviour is exactly the same on this webserver (OSF1, Apache
1.3.27, PHP 4.2.3, GD 1.8.4) as on my home system (Win2k, Apache
2.0.43, PHP 4.3.0-dev, GD 2 built-in). The png image
(http://www.phys.uu.nl/~varsity/rowperfect/png/grid.png) renders
faultless in IE6, Moz121, Corel Photopaint 9. If you want I can send
the grid.php/test.php source.

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21668&edit=1


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

Reply via email to