Home Tutorial Php Phpgd PHP GD Color Transparency Using Alpha Blending

 
 

Share on Google+Share on Google+
PHP GD Color Transparency Using Alpha Blending
Posted on: November 13, 2009 at 12:00 AM
Advertisement
This example shows how to do Color Transparency Using Alpha Blending in php gd.

<?php

define("WIDTH", 300);

define("HEIGHT", 300);

$img = imagecreatetruecolor(WIDTH, HEIGHT);

$black = imagecolorallocate($img, 0, 0, 0);

$yellow = imagecolorallocate($img, 0xFF, 0xFF, 00);

$red = imagecolorallocate($img, 255, 0, 0);

$blue_t = imagecolorallocatealpha($img, 0, 0, 0xFF, 0x40);

imagefill($img, 1, 1, $black);

imageline($img, 0,0, WIDTH-1, HEIGHT-1, $blue_t);

imagefilledrectangle($img, (WIDTH/2)-50, (HEIGHT/2)-50, (WIDTH/2)+50, (HEIGHT/2)+50, $yellow);

imagefilledrectangle($img, (WIDTH/2)-30, (HEIGHT/2)-30, (WIDTH/2)+30, (HEIGHT/2)+30, $red);

imagefilledrectangle($img, 10, 10, WIDTH-11, HEIGHT-11, $blue_t);

header("Content-Type: image/png");

imagepng($img);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD Color Transparency Using Alpha Blending:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 13, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com