Jump to content

having trouble with imagecolorallocatealpha


c_shelswell

Recommended Posts

Hi I'm trying to create a text image with a transparent background. I can create the image no problem but seem to get stuck with the transparent background it just keeps making it a solid colour.

 

Here's my code:

function createHeadings($string, $bckCol, $txtCol, $path, $name, $dlcLocation, $fontSize)
{
$font = './fonts/arialbd.ttf';

//(FONT_SIZE, ANGLE, FONT, $STRING)
$bb = imagettfbbox($fontSize, 0, $font, $string);

$w = abs($bb[4] - $bb[0]);
$h = abs($bb[5] - $bb[1]);

$h = 11;

$im = imagecreatetruecolor($w + 5, $h+;

$textColour = imagecolorallocate($im, $txtCol[0], $txtCol[1], $txtCol[2]);
$backColour = imagecolorallocatealpha($im, $bckCol[0], $bckCol[1], $bckCol[2], 0);

imagefilledrectangle($im, 0, 0, $w+5, 29, $backColour);

// (IMAGE, FONT_SIZE, ANGLE, X-START, Y-START, COLOUR, FONT, TEXT
imagettftext($im, $fontSize, 0, 01, $h+2, $textColour, $font, $string);

$finalPath = "../$dlcLocation/$path/$name";

imagegif($im, $finalPath, 100);
echo "<img src='$finalPath'><p />";

imagedestroy($im);
}

 

from what i could see in the manual I could just use imagecolorallocatealpha?

 

Thanks for any help

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.