GD2 palette question
Posted: Fri Aug 18, 2006 5:14 pm
(With 8-bit png, from database.)
How come this says the colors are not in the palette.
Looping thour all the pixels:
The only colour it says it is in the palette, is the colour that is in the palette with id=0, but this says it has id=9, which is black in the palette.
Outputted it looks just like it should be. And if I save it and open in graphics editor, the palette is just like it should be.
How come this says the colors are not in the palette.
Looping thour all the pixels:
The only colour it says it is in the palette, is the colour that is in the palette with id=0, but this says it has id=9, which is black in the palette.
Code: Select all
function get_terrain($x,$y, $style='id') {
$rgb = imagecolorat($this->{'terrain_image'}, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> & 0xFF;
$b = $rgb & 0xFF;
$tmp_id = "$r.$g.$b";
switch ($style){
[cut]
case 'palette_id':
return imagecolorexact($this->{'terrain_image'},$r,$g,$b);
break;
}
[cut]