need help allocating string to a specific color
Posted: Thu Feb 25, 2010 5:29 am
Hello! a PHP newbie right here..
I need to allocate a string to a particular color..
I have a code but it only outputs a string assigned to white(255 255 255)
any other ideas or alternatives? they are greatly appreciated.. thanks!!
I need to allocate a string to a particular color..
I have a code but it only outputs a string assigned to white(255 255 255)
Code: Select all
for ($x = 0; $x < $width; $x++) {
for ($y = 0; $y < $height; $y++) {
$colorIndex = ImageColorAt($img, $x, $height - 1 - $y);
$color = ImageColorsForIndex($img, $colorIndex);
$color['red']=intval((($color['red'])+15)/32)*32;
$color['green']=intval((($color['green'])+15)/32)*32;
$color['blue']=intval((($color['blue'])+15)/32)*32;
// symbol per color
switch ($color) {
case ($color['red'] = 255 and $color['green'] = 255 and $color['blue'] = 255) :
$assignedsymbol = "00";
break;
case ($color['red'] = 148 and $color['green'] = 91 and $color['blue'] = 128) :
$assignedsymbol = "01";
break;
case ($color['red'] = 206 and $color['green'] = 148 and $color['blue'] = 186) :
$assignedsymbol = "02";
break;
case ($color['red'] = 000 and $color['green'] = 255 and $color['blue'] = 000) :
$assignedsymbol = "03";
break;
............
default:
$assignedsymbol == "0";
}