You are here

function ImageToolkitGdTestCase::colorsAreEqual in Drupal 7

Function to compare two colors by RGBa.

1 call to ImageToolkitGdTestCase::colorsAreEqual()
ImageToolkitGdTestCase::testManipulations in modules/simpletest/tests/image.test
Since PHP can't visually check that our images have been manipulated properly, build a list of expected color values for each of the corners and the expected height and widths for the final images.

File

modules/simpletest/tests/image.test, line 230
Tests for core image handling API.

Class

ImageToolkitGdTestCase
Test the core GD image manipulation functions.

Code

function colorsAreEqual($color_a, $color_b) {

  // Fully transparent pixels are equal, regardless of RGB.
  if ($color_a[3] == 127 && $color_b[3] == 127) {
    return TRUE;
  }
  foreach ($color_a as $key => $value) {
    if ($color_b[$key] != $value) {
      return FALSE;
    }
  }
  return TRUE;
}