public SpPixels GetSubset(int x, int y, int w, int h) { if (w < 0) { w = -w; x -= w; } if (h < 0) { h = -h; y -= h; } var o = new SpPixels(w, h); for (var oy = 0; oy < h; oy++) { for (var ox = 0; ox < w; ox++) { o.SetPixel(ox, oy, GetPixel(ox + x, oy + y)); } } return(o); }
public SpPixels GetFlippedVertically() { var o = new SpPixels(width, height); for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { o.SetPixel(x, height - y - 1, GetPixel(x, y)); } } return(o); }
public SpPixels GetFlippedHorizontally() { var o = new SpPixels(width, height); for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { o.SetPixel(width - x - 1, y, GetPixel(x, y)); } } return(o); }
public SpPixels GetRotated270() { var o = new SpPixels(height, width); for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { o.SetPixel(height - y - 1, x, GetPixel(x, y)); } } return(o); }
public SpPixels GetRotated90() { var o = new SpPixels(height, width); for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { var c = GetPixel(x, y); o.SetPixel(y, width - x - 1, c); } } return(o); }