public int GetLocalPixel(int x, int y) { int newX = x.Clamp(0, this.bounds.Width - 1); int newY = y.Clamp(0, this.bounds.Height - 1); //Debug.Assert(newX == x && newY == y); return this.pixels[newY * this.bounds.Width + newX]; }