PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have been working on something for the past couple weeks, and just today something has come to my attention that previous testing did not show...the problem itself seems to be colors contrasting when they are all rendered into an image, here is an example
This one is rendered wrong
but with a different background loaded it renders properly
Is there something im missing with GD that might cause this...all thats happening is the image is rendered using a background chosen by the user, then the avatar on the left side is copied in from an image chosen by the user.
I have been working on something for the past couple weeks, and just today something has come to my attention that previous testing did not show...the problem itself seems to be colors contrasting when they are all rendered into an image, here is an example
This one is rendered wrong
but with a different background loaded it renders properly
Is there something im missing with GD that might cause this...all thats happening is the image is rendered using a background chosen by the user, then the avatar on the left side is copied in from an image chosen by the user.
if ($result['custombg'] == 1)
{
//if custom bg is set in the database, then we get it from their folder instead of the normal folder.
$im = imagecreatefrompng("backgrounds/users/$result[username]/".$result['background']);
}else{
//lets use the normal bg's if they arent using a custom one.
$im = imagecreatefrompng("backgrounds/$result[background]");
}
//if customav is set in the database, lets load the avatar from their directory.
if($result['customav'] == 1){
//then we create the avatar from the image they uploaded..this didnt work so well last time I tried...dunno why, but hopefully it works now.
$av = imagecreatefrompng("avatars/users/$result[username]/".$result['avatar']);
}else{
$av = imagecreatefrompng("avatars/".$result['avatar']);
}
//now, lets copy the avatar to the correct spot on the sig..weird size, but had to do it.
$avcopy=imagecopy($im,$av,1,19,0,0,98,80);
//end that
//Colors that will be used
//$bgcolor=imagecolorallocate($im,255,255,200);
$color = $result[txtcol];
//$r=255;
//$g=0;
//$b=0;
//now this was a little complicated...takes the hex values out of the database, and converts it into decimal for the color allocate function to work....
$tc=imagecolorallocate($im, hexdec('0x' . $color{0} . $color{1}), hexdec('0x' . $color{2} . $color{3}), hexdec('0x' . $color{4} . $color{5}));
$lc=imagecolorallocate($im,0,0,0);
Your background image is an 8bit PNG file, consequently it's limited to 256 different colours. Save it as a 24bit or 32bit image and the problem will go away.
Alternatively create a true color image with imagecreatetruecolor() and copy everything on to it rather than loading the background and copying everything to that.