function ToolkitGdTest::getPixelColor

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::getPixelColor()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::getPixelColor()
  3. 10 core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::getPixelColor()

Function for finding a pixel's RGBa values.

1 call to ToolkitGdTest::getPixelColor()
ToolkitGdTest::testManipulations in core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
Tests height, width and color for the corners for the final images.

File

core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php, line 97

Class

ToolkitGdTest
Tests for the GD image toolkit.

Namespace

Drupal\KernelTests\Core\Image

Code

public function getPixelColor(ImageInterface $image, int $x, int $y) : array {
    $toolkit = $image->getToolkit();
    $color_index = imagecolorat($toolkit->getImage(), $x, $y);
    $transparent_index = imagecolortransparent($toolkit->getImage());
    if ($color_index == $transparent_index) {
        return [
            0,
            0,
            0,
            127,
        ];
    }
    return array_values(imagecolorsforindex($toolkit->getImage(), $color_index));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.