PHP GD: need to find out an alpha quantity
Posted: Mon Jun 21, 2010 5:31 pm
Imagine this. I have a pixel of color (255,0,0) [red]. No someone painted on it with white color with * alpha. I know the background color, I know with what color it was painted over, I need to get the alpha of the painted over color. How?
So far we have:
So far we have:
Code: Select all
$im = imagecreatefrompng('public/images/bg-tmp.png');
// we need to find a nearest match for this array in every pixel
/*$colors = array(
array(255, 255, 255, 100),
array(255, 255, 255, 75),
array(255, 255, 255, 50),
array(255, 255, 255, 25),
array(255, 255, 255, 0),
);*/
// finding out the pixel color
$rgb = imagecolorat($im, 0, 6);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
var_dump($r, $g, $b);