Click to See Complete Forum and Search --> : ImageTransparency
flame_211
Oct 22nd, 2003, 08:29 PM
I am having problems with Image Transparency, My images I have go in as Transparent, but when I out put them, they arent. Am I doing my imagetransparency function wrong?
function player($guy, $shirt) {
$image = ImageCreateTrueColor($im_x_guy, $im_y_guy);
$im_guy = ImageCreateFromPNG("images/rpg/clothing/$guy");
$im_x_guy = ImageSX($im_guy);
$im_y_guy = ImageSY($im_guy);
$im_color = ImageColorAllocate($image, 0, 0, 0);
ImageColorTransparent($image, $im_color);
ImageCopy($image, $im_guy, 0, 0, 0, 0, $im_x_guy, $im_y_guy);
if ($shirt !== '0'){
$im_shirt = ImageCreateFromPNG("images/rpg/clothing/$shirt");
$im_x_shirt = ImageSX($im_shirt);
$im_y_shirt = ImageSY($im_shirt);
ImageCopy($image, $im_shirt, 0, 0, 0, 0, $im_x_shirt, $im_y_shirt);
}
header ("Content-type: image/png");
ImagePNG($image);
ImageDestroy($image);}
Any help would be GREATLY apreciated.
The Hobo
Oct 22nd, 2003, 08:32 PM
Did you check out any of the comments in the PHP manual to see if they'd help? http://www.php.net/ImageColorTransparent
flame_211
Oct 22nd, 2003, 08:37 PM
Yeah, I did, I tried like 3 of them, but It doesnt seem to work. Could it be that my server doesnt support ImageTransparency for some reason?
kows
Oct 22nd, 2003, 09:21 PM
I'm not totally sure if this will do it, but you could try moving your declaration of the transparent color to after the if statement..
if ($shirt !== '0'){
$im_shirt = ImageCreateFromPNG("images/rpg/clothing/$shirt");
$im_x_shirt = ImageSX($im_shirt);
$im_y_shirt = ImageSY($im_shirt);
ImageCopy($image, $im_shirt, 0, 0, 0, 0, $im_x_shirt, $im_y_shirt);
}
//move transparency declaration
ImageColorTransparent($image, $im_color);
header ("Content-type: image/png");
ImagePNG($image);
ImageDestroy($image);}
flame_211
Oct 23rd, 2003, 09:39 AM
Alright, Ill try it out and let you know how it turns out.
phpman
Oct 25th, 2003, 01:25 AM
does your server have GD Library 2.0, because you have to have it for it to work.
flame_211
Oct 27th, 2003, 04:24 PM
["GD Version"]=> string(27) "bundled (2.0.15 compatible)"
thats the version I have, it should work shouldnt it?:confused:
phpman
Oct 27th, 2003, 04:34 PM
where did you get that? what does it say when you run phpinfo() ?
flame_211
Oct 28th, 2003, 08:57 PM
Hrm... It says it in phpinfo? ill have to check that, anyways, i got that from gd_info();, however its best to probably display it with var dump:<?php
var_dump(gd_info());
?>
flame_211
Oct 28th, 2003, 09:05 PM
according to phpinfo() i have 2.0.15
phpman
Oct 28th, 2003, 09:14 PM
where are these coming from?
$im_x_guy, $im_y_guy
also I don't know any phpinfo that displays the full version. mine says "bundled (2.0 compatible)"
anyway, where are those variables coming from?
kows
Oct 29th, 2003, 10:07 PM
Originally posted by phpman
where are these coming from?
$im_x_guy, $im_y_guy
also I don't know any phpinfo that displays the full version. mine says "bundled (2.0 compatible)"
anyway, where are those variables coming from?
did you read the posted code?
function player($guy, $shirt) {
$image = ImageCreateTrueColor($im_x_guy, $im_y_guy);
$im_guy = ImageCreateFromPNG("images/rpg/clothing/$guy");
$im_x_guy = ImageSX($im_guy);
$im_y_guy = ImageSY($im_guy);
$im_color = ImageColorAllocate($image, 0, 0, 0);
phpman
Oct 29th, 2003, 10:25 PM
uhh look again
function player($guy, $shirt) {
$image = ImageCreateTrueColor($im_x_guy, $im_y_guy);
$im_guy = ImageCreateFromPNG("images/rpg/clothing/$guy");
$im_x_guy = ImageSX($im_guy);
$im_y_guy = ImageSY($im_guy);
he calls them before he sets them.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.