sammysmee Posted January 4, 2008 Share Posted January 4, 2008 Hello there Me and my coder have been trying to fix this for at least 6 hours and our heads are ready to explode! we really need your help! basically, we are making 'custom' avatars for our RPG game, we have managed to make a code to layer PNGS using GD however we cannot manage 24-bit PNG transparency! We got as far as managing to get the 'bottom' layer Transparent, but thats as far as we can get. We've tried hundreds of codes and scrawled the net, with no avail! here is the code: <?php header ("Content-type: image/png"); //$imgbackground=imageCreateFromPng("paperdoll/background.png"); $imgTorso=imageCreateFromPng("paperdoll/human_body.png"); $imgHair=imageCreateFromPng("paperdoll/malehair1_2.png"); $imgEyes=imageCreateFromPng("paperdoll/eyes1.png"); $imgEars=imageCreateFromPng("paperdoll/human_ears.png"); $imgMouth=imageCreateFromPng("paperdoll/mouth1.png"); $imgBody=imageCreateFromPng("paperdoll/scivvies.png"); imagecolortransparent($imgTorso,imagecolorat($imgTorso,0,0)); imagecolortransparent($imgHair,imagecolorat($imgHair,0,0)); imagecolortransparent($imgEyes,imagecolorat($imgEyes,0,0)); imagecolortransparent($imgEars,imagecolorat($imgEars,0,0)); imagecolortransparent($imgMouth,imagecolorat($imgMouth,0,0)); imagecolortransparent($imgBody,imagecolorat($imgBody,0,0)); // imageAlphaBlending($imgbackground, true); imageAlphaBlending($imgTorso, true); imageAlphaBlending($imgHair, true); imageAlphaBlending($imgEyes, true); imageAlphaBlending($imgEars, true); imageAlphaBlending($imgMouth, true); imageAlphaBlending($imgBody, true); //imageSaveAlpha($imgbackground, true); imageSaveAlpha($imgTorso, true); imageSaveAlpha($imgHair, true); imageSaveAlpha($imgEyes, true); imageSaveAlpha($imgEars, true); imageSaveAlpha($imgMouth, true); imageSaveAlpha($imgBody, true); //imagecolortransparent($imgbackground,imagecolorat($imgbackground,0,0)); $insert6_x = imagesx($imgTorso); $insert6_y = imagesy($imgTorso); $insert_x = imagesx($imgHair); $insert_y = imagesy($imgHair); $insert2_x = imagesx($imgEyes); $insert2_y = imagesy($imgEyes); $insert3_x = imagesx($imgEars); $insert3_y = imagesy($imgEars); $insert4_x = imagesx($imgMouth); $insert4_y = imagesy($imgEars); $insert5_x = imagesx($imgBody); $insert5_y = imagesy($imgEars); imagecopymerge($imgTorso,$imgTorso,0,0,0,0,$insert6_x,$insert6_y,100); imagecopymerge($imgTorso,$imgHair,0,0,0,0,$insert_x,$insert_y,100); imagecopymerge($imgTorso,$imgEyes,0,0,0,0,$insert2_x,$insert2_y,100); imagecopymerge($imgTorso,$imgEars,0,0,0,0,$insert3_x,$insert3_y,100); imagecopymerge($imgTorso,$imgMouth,0,0,0,0,$insert4_x,$insert4_y,100); imagecopymerge($imgTorso,$imgBody,0,0,0,0,$insert5_x,$insert5_y,100); //imagecopymerge($imgbackground,$imgbackground,0,0,0,0,$insert6_x,$insert6_y,100); imagepng($imgTorso,"",100); ?> and the result: http://sammystudio.co.uk/majv1/avatar3.php - somebody help! hehe! thanks for reading!!! Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/ Share on other sites More sharing options...
Barand Posted January 4, 2008 Share Posted January 4, 2008 The transparent color is an image property - ie one per image. You can define transparent colors with imagecolorallocatealpha() Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430673 Share on other sites More sharing options...
sammysmee Posted January 4, 2008 Author Share Posted January 4, 2008 that may be true but i wouldnt know where to put it/what to change ^^ (im a noob!) Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430692 Share on other sites More sharing options...
sammysmee Posted January 4, 2008 Author Share Posted January 4, 2008 if you could show me what i'm meant to do by tweaking my code, that'd be very helpful! ^^ Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430743 Share on other sites More sharing options...
Barand Posted January 4, 2008 Share Posted January 4, 2008 what's wrong with the result at http://sammystudio.co.uk/majv1/avatar3.php ? Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430753 Share on other sites More sharing options...
sammysmee Posted January 4, 2008 Author Share Posted January 4, 2008 the pngs are jagged the only way around this is to resize the file which comes out blurry >< Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430800 Share on other sites More sharing options...
sammysmee Posted January 4, 2008 Author Share Posted January 4, 2008 Dont worry! We've cracked it basically we resized the pngs (indexed ones) so they were 200 wide then we added image resize and had it autoresize to 120 wide this iliminates the 'sharp' edges! Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430816 Share on other sites More sharing options...
Barand Posted January 4, 2008 Share Posted January 4, 2008 Ah, good. I was looking at antialiasing but that doesn't have alpha support or work with transparent colors. Link to comment https://forums.phpfreaks.com/topic/84532-solved-png-transparency-on-gd/#findComment-430818 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.