Search code examples
phptransparencyskinminecraft

What Conditions Make A Minecraft Hat Transparent


Basically I'm writing a PHP script that displays a Minecraft skin. I understand that the only part of a Minecraft skin that's able to be transparent is the Mask overlay area, or "Hat". The script works great until I reach a skin like Notch's (creator of Minecraft) who has an all black background besides the main body parts. I know that solid black (#000000) can't be a transparency key because I've seen instances where the skin has a black part on the mask, but still transparency. Also, when I open up my personal skin in Photoshop the background area is almost black - #101010 which is RGB(16, 16, 16), but still appears transparent in game. My question is how can I determine if a pixel is transparent for the hat? I may be over thinking this.

Here's Notch's Skin -

Mine - enter image description here

Mine in Photoshop -

Could I be wrong about the black transparency key?


Solution

  • An image that contains transparency can have the transparent color set to anything. Most often when I create files like that, I actually make the transparent color garish, like a bright hot pink or something, so that it is obvious. However, the exact transparency itself is set in the file, not in php itself. Using a program like photoshop, you can go into the image options (example http://answers.yahoo.com/question/index?qid=20090430191631AA61iQJ )and set the exact RBG that you want for it.

    If you are having trouble displaying the files as they are meant to be, I am going to assume that you are doing some on the fly manipulation on the image - which is likely causing the transparency information to be lost.