You are here

protected function ImageEffectsTestBase::getPixelColor in Image Effects 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::getPixelColor()
  2. 8.2 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::getPixelColor()

Function for finding a pixel's RGBa values.

14 calls to ImageEffectsTestBase::getPixelColor()
AutoOrientTest::testAutoOrientAllTags in tests/src/Functional/Effect/AutoOrientTest.php
Auto Orientation effect test, all EXIF orientation tags.
BackgroundTest::testBackgroundEffect in tests/src/Functional/Effect/BackgroundTest.php
Background effect test.
BrightnessTest::testBrightnessEffect in tests/src/Functional/Effect/BrightnessTest.php
Brightness effect test.
ColorShiftTest::testColorShiftEffect in tests/src/Functional/Effect/ColorShiftTest.php
Color Shift effect test.
ContrastTest::testContrastEffect in tests/src/Functional/Effect/ContrastTest.php
Contrast effect test.

... See full list

File

tests/src/Functional/ImageEffectsTestBase.php, line 315

Class

ImageEffectsTestBase
Base test class for image_effects tests.

Namespace

Drupal\Tests\image_effects\Functional

Code

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