rotate270 method

RasterImage rotate270()

270 Grad im Uhrzeigersinn (entspricht copyRotate(img, 270) aus image 3.x).

Implementation

RasterImage rotate270() {
  final out = Uint8List(rgba.length);
  final int nw = height, nh = width;
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      final src = (y * width + x) * 4;
      // 270 cw: (x,y) -> (y, width-1-x)
      final int dx = y;
      final int dy = width - 1 - x;
      final dst = (dy * nw + dx) * 4;
      out[dst] = rgba[src];
      out[dst + 1] = rgba[src + 1];
      out[dst + 2] = rgba[src + 2];
      out[dst + 3] = rgba[src + 3];
    }
  }
  return RasterImage(nw, nh, out);
}