22 $a = ($value >> 24) & 0xFF;
23 $r = ($value >> 16) & 0xFF;
24 $g = ($value >> 8) & 0xFF;
26 $a = $this->rgb2alpha($a);
28 $this->setPixel($r, $g, $b, $a);
39 $array = array_values($array);
41 if (count($array) == 4) {
44 list($r, $g, $b, $a) = $array;
46 } elseif (count($array) == 3) {
49 list($r, $g, $b) = $array;
53 $this->setPixel($r, $g, $b, $a);
66 $this->setPixel($color[0], $color[1], $color[2], $color[3]);
79 if (is_a($value,
'\ImagickPixel')) {
80 $this->pixel = $value;
95 $this->setPixel($r, $g, $b);
110 $this->setPixel($r, $g, $b, $a);
125 return intval(($a << 24) + ($r << 16) + ($g << 8) + $b);
137 return sprintf(
'%s%02x%02x%02x', $prefix,
166 return sprintf(
'rgba(%d, %d, %d, %.2f)',
183 $color_tolerance = round($tolerance * 2.55);
184 $alpha_tolerance = round($tolerance);
187 'r' => abs($color->getRedValue() - $this->getRedValue()),
188 'g' => abs($color->getGreenValue() - $this->getGreenValue()),
189 'b' => abs($color->getBlueValue() - $this->getBlueValue()),
190 'a' => abs($color->getAlphaValue() - $this->getAlphaValue())
194 $delta[
'r'] > $color_tolerance
or
195 $delta[
'g'] > $color_tolerance
or
196 $delta[
'b'] > $color_tolerance
or
197 $delta[
'a'] > $alpha_tolerance
208 return intval(round($this->pixel->getColorValue(\Imagick::COLOR_RED) * 255));
218 return intval(round($this->pixel->getColorValue(\Imagick::COLOR_GREEN) * 255));
228 return intval(round($this->pixel->getColorValue(\Imagick::COLOR_BLUE) * 255));
238 return round($this->pixel->getColorValue(\Imagick::COLOR_ALPHA), 2);
246 private function setPixel($r, $g, $b, $a =
null)
248 $a = is_null($a) ? 1 : $a;
250 return $this->pixel = new \ImagickPixel(
251 sprintf(
'rgba(%d, %d, %d, %.2f)', $r, $g, $b, $a)
271 private function rgb2alpha($value)
274 return (
float) round($value/255, 2);