Renlok Posted January 6, 2008 Share Posted January 6, 2008 Im trying (and failing) to make a pet recolouring script for a game. <?php //coords $base_x = array(100); $base_y = array(100); $eyes_x = array(43, 20); $eyes_y = array(83, 81); $detail_x = array(20,24,28,39,34,39,48,44,57,56,95,91,98); $detail_y = array(70,60,67,64,58,51,47,41,41,32,125,141,163); //testing page header ("Content-type: image/png"); $dogoverlay = imagecreatefrompng("images/misk-junk/dog-over.png"); $dogbase = imagecreatefrompng("images/misk-junk/dog-base.png"); $dogeyes = imagecreatefrompng("images/misk-junk/dog-eyes.png"); $dogdetails = imagecreatefrompng("images/misk-junk/dog-detail.png"); //get random colours to test with $newcolour1 = imagecolorallocate($dogbase, 56, 160, 156); $newcolour2 = imagecolorallocate($dogeyes, 253, 175, 4); $newcolour3 = imagecolorallocate($dogeyes, 50, 207, 70); $border = imagecolorallocate($dogbase, 10, 10, 10); //recolour base imagefilltoborder($dogbase, $base_x[0], $base_y[0], $border, $newcolour1); //recolour eyes for($i = 0; $i<count($eyes_x); $i++){ imagefilltoborder($dogeyes, $eyes_x[$i], $eyes_y[$i], $border, $newcolour2); } //recolour details for($i = 0; $i<count($detail_x); $i++){ imagefilltoborder($dogeyes, $detail_x[$i], $detail_y[$i], $border, $newcolour3); } imagecopymerge($dogeyes,$dogbase,0,0,0,0,$width,$height,100); imagecopymerge($dogdetails,$dogbase,0,0,0,0,$width,$height,100); imagecopymerge($dogoverlay,$dogbase,0,0,0,0,$width,$height,100); imagepng($dogbase,NULL,100); //clean up the image imagedestroy($dogbase); imagedestroy($dogoverlay); imagedestroy($dogeyes); imagedestroy($dogdetails); ?> the problems i have are - none of the images actually load up correctly, they either have a black background when its sposed to be transparent or they have random blobs of black in random places for no reason. No idea why this happens. - all that shows is a wash off teal but i think thats caused because of the problems above. and im new at using GD so i tend to make loads of really stupid mistakes. Also thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/84736-gd-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.