Пример #1
0
function imagecreatefrombmp($filename)
{
    return BMP::imagecreatefrombmp($filename);
}
Пример #2
0
    {
        $r = unpack("V", $n);
        return $r[1];
    }
    private static function dword($n)
    {
        return pack("V", $n);
    }
    private static function word($n)
    {
        return pack("v", $n);
    }
}
$file = 'trabaja.bmp';
list($width, $height) = getimagesize($file);
$img = BMP::imagecreatefrombmp($file);
$lines = file('php://stdin');
$lines = array_map('trim', $lines);
foreach ($lines as $line) {
    $y = substr($line, 1, strlen($line) - 1);
    $which = strtolower(substr($line, 0, 1));
    $out = 0;
    for ($i = 0; $i < $width; $i++) {
        $rgb = imagecolorat($img, $i, $y);
        $r = $rgb >> 16 & 0xff;
        $g = $rgb >> 8 & 0xff;
        $b = $rgb & 0xff;
        $out += ${$which};
    }
    echo $out + 1 . PHP_EOL;
}