function GdToolkitImageManipulationTestBase::getPixelColor

Function for finding a pixel's RGBa values.

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

File

core/tests/Drupal/KernelTests/Core/Image/GdToolkitImageManipulationTestBase.php, line 94

Class

GdToolkitImageManipulationTestBase
GD image toolkit image manipulation test base class.

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.