flipVertical function

Image flipVertical(
  1. Image src
)

Flip the src image vertically.

Implementation

Image flipVertical(Image src) {
  final w = src.width;
  final h = src.height;
  final h2 = h ~/ 2;
  for (var y = 0; y < h2; ++y) {
    final y1 = y * w;
    final y2 = (h - 1 - y) * w;
    for (var x = 0; x < w; ++x) {
      final t = src[y2 + x];
      src[y2 + x] = src[y1 + x];
      src[y1 + x] = t;
    }
  }
  return src;
}