Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.