brighten method

Future<Image> brighten(
  1. double amount
)

Change each pixel's color to be brighter and return a new Image.

The amount is a double value between 0 and 1.

Implementation

Future<Image> brighten(double amount) async {
  assert(amount >= 0 && amount <= 1);

  final pixelData = await pixelsInUint8();
  final newPixelData = Uint8List(pixelData.length);

  for (var i = 0; i < pixelData.length; i += 4) {
    final color = Color.fromARGB(
      pixelData[i + 3],
      pixelData[i + 0],
      pixelData[i + 1],
      pixelData[i + 2],
    ).brighten(amount);

    newPixelData[i] = color.red;
    newPixelData[i + 1] = color.green;
    newPixelData[i + 2] = color.blue;
    newPixelData[i + 3] = color.alpha;
  }
  return fromPixels(newPixelData, width, height);
}