Staggan Posted July 8, 2013 Share Posted July 8, 2013 Hello I have looked at numerous posts on this but I seem unable to get it to work.... I trying to make the background to a generated PNG transparent... below is the code $dimensions = $this->getDimens($fh, $lw, $hpad, $vpad); $this->im = imagecreate($dimensions['x'], $dimensions['y']); $bg = iimagecolorallocate$this->im, 255, 255, 255); // Set background color. imagecolortransparent($this->im, $bg); $this->tc = imagecolorallocate($this->im, 0, 0, 0); // Text color. $this->mkStr($dimensions['x'] - $hpad - imagefontwidth(LFONT)*strlen($tourName), $dimensions['y'] - $vpad/2, $tourName, LFONT); // Print tournament name. Currently I just get a black image... Any suggestions would be greatly appreciated Thanks Quote Link to comment Share on other sites More sharing options...
kicken Posted July 8, 2013 Share Posted July 8, 2013 (edited) Mark the image to save the alpha channel details using imagesavealpha and set it to true. Then allocate your background color using imagecolorallocatealpha and set the alpha parameter to 127. Floodfill the image using imagefill with the background color, then you should get your transparent background. Edited July 8, 2013 by kicken Quote Link to comment Share on other sites More sharing options...
Staggan Posted July 8, 2013 Author Share Posted July 8, 2013 Hello It still isn't working.. My code is now this: // Initial calls. $dimensions = $this->getDimens($fh, $lw, $hpad, $vpad); $this->im = imagecreate($dimensions['x'], $dimensions['y']); $bg = imagecolorallocate($this->im, 255, 255, 255); // Set background color. imagesavealpha($this->im, true); imagecolorallocatealpha($this->im, 255, 255, 255, 127); imagefill($this->im, 255, 255, 255); imagecolortransparent($this->im, $bg); I get a white background now..... This page is being shown via an iframe.. and I want the background on the calling page to show through.... Am I missing something? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.