public static Matrix <T> Transformed <T>( this Matrix <T> matrix, ImageTrafo rotation) { long sx = matrix.Size.X, sy = matrix.Size.Y; long dx = matrix.Delta.X, dy = matrix.Delta.Y; switch (rotation) { case ImageTrafo.Rot0: return(matrix); case ImageTrafo.Rot90: return(matrix.SubMatrix(sx - 1, 0, sy, sx, dy, -dx)); case ImageTrafo.Rot180: return(matrix.SubMatrix(sx - 1, sy - 1, sx, sy, -dx, -dy)); case ImageTrafo.Rot270: return(matrix.SubMatrix(0, sy - 1, sy, sx, -dy, dx)); case ImageTrafo.MirrorX: return(matrix.SubMatrix(sx - 1, 0, sx, sy, -dx, dy)); case ImageTrafo.Transpose: return(matrix.SubMatrix(0, 0, sy, sx, dy, dx)); case ImageTrafo.MirrorY: return(matrix.SubMatrix(0, sy - 1, sx, sy, dx, -dy)); case ImageTrafo.Transverse: return(matrix.SubMatrix(sx - 1, sy - 1, sy, sx, -dy, -dx)); } throw new ArgumentException(); }