Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Gd Library Help

Junior Spellweaver
Joined
Nov 5, 2013
Messages
147
Reaction score
57
Hi!
I was trying to make a 'api' for the Habbo Camera, but that need experience in GD Library and i don't have so much.

So, i need help about this part:
this image came with Black Background
i need to know how to transform the black background in transparent each dark level in each pixel
for get this effect


if anyone know, i would be grateful in know about that ^^
 
Junior Spellweaver
Joined
Nov 5, 2013
Messages
147
Reaction score
57
I've already readed this and i didn't understand that i have to get the colors of sprite and add to backgeound colors xD

Thanks for help Joopie <3
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
Can't you just merge two PNG images to get that effect? Like, draw habbo picture first, then draw the effect from a semi-transparent PNG on top of it..? You can do this in JavaScript Canvas pretty easily and submit the bytes for the image using a form and some AJAX... Or PHP if you really wanted to.

If you really need to find all of the black pixels with 100% alpha in an image, and convert those pixels to 0 alpha before overlaying the result on top of another image, you need to loop through all of the pixels in the image, do a conditional statement to see if the pixel is black, and if so, set the alpha to be completely transparent. In JS + Canvas, you get all of the pixels using a function. In PHP, you loop the width and height, and do some code inside the two loops...
PHP:
$width = 500;
$height = 500;
for ($x = 0; $x += 1; $x < $width) {
  for ($y = 0; $y += 1; $y < $height) {
    // figure out if the pixel is the one u want to change..
    // if so, change it..
  }
}
In JS+canvas you do basically the same thing, but you have the option of doing it in a more functional style if you want to.

Then draw the generated image on top of the other one.

 
Last edited:
Back
Top