hdrGamma function

HdrImage hdrGamma (
  1. HdrImage hdr,
  2. {double gamma: 2.2}
)

Apply gamma scaling to the HDR image, in-place.

Implementation

HdrImage hdrGamma(HdrImage hdr, {double gamma = 2.2}) {
  for (var y = 0; y < hdr.height; ++y) {
    for (var x = 0; x < hdr.width; ++x) {
      var r = pow(hdr.getRed(x, y), 1.0 / gamma);
      var g = pow(hdr.getGreen(x, y), 1.0 / gamma);
      var b = pow(hdr.getBlue(x, y), 1.0 / gamma);

      hdr.setRed(x, y, r);
      hdr.setGreen(x, y, g);
      hdr.setBlue(x, y, b);
    }
  }

  return hdr;
}