You are here

function _imageapi_gd_pixel_contrast in ImageAPI 6

Same name and namespace in other branches
  1. 5 imagefilter.inc \_imageapi_gd_pixel_contrast()
1 string reference to '_imageapi_gd_pixel_contrast'
imagefilter in ./imagefilter.inc

File

./imagefilter.inc, line 72

Code

function _imageapi_gd_pixel_contrast(&$r, &$g, &$b, &$a, $contrast) {

  // normalize color value between -0.5 - 0.5
  // multiply by contrast value to accentuate positive/negative value.
  // denormalize to 0-255 range.
  $r = (($r / 255 - 0.5) * $contrast + 0.5) * 255;
  $g = (($g / 255 - 0.5) * $contrast + 0.5) * 255;
  $b = (($b / 255 - 0.5) * $contrast + 0.5) * 255;
}