ColorThief\Image\Adapter\GmagickImageAdapter::getPixelColor PHP Метод

getPixelColor() публичный Метод

public getPixelColor ( $x, $y )
    public function getPixelColor($x, $y)
    {
        $cropped = clone $this->resource;
        // No need to modify the original object.
        $histogram = $cropped->cropImage(1, 1, $x, $y)->getImageHistogram();
        $pixel = array_shift($histogram);
        // Un-normalized values don't give a full range 0-1 alpha channel
        // So we ask for normalized values, and then we un-normalize it ourselves.
        $colorArray = $pixel->getColor(true, true);
        $color = new \stdClass();
        $color->red = (int) round($colorArray['r'] * 255);
        $color->green = (int) round($colorArray['g'] * 255);
        $color->blue = (int) round($colorArray['b'] * 255);
        $color->alpha = (int) round($pixel->getcolorvalue(\Gmagick::COLOR_OPACITY) * 127);
        return $color;
    }