contrast function

void contrast(
  1. Uint8List bytes,
  2. num adj
)

Implementation

void contrast(Uint8List bytes, num adj) {
  adj *= 255;
  double factor = (259 * (adj + 255)) / (255 * (259 - adj));
  for (int i = 0; i < bytes.length; i += 4) {
    bytes[i] = clampPixel((factor * (bytes[i] - 128) + 128).round());
    bytes[i + 1] = clampPixel((factor * (bytes[i + 1] - 128) + 128).round());
    bytes[i + 2] = clampPixel((factor * (bytes[i + 2] - 128) + 128).round());
  }
}