public double GetFluidAmount(int x, int y, PixelRetrievalOptions option) { if (x >= 0 && x < t_grid.Length && y >= 0 && y < t_grid[0].Length) { return(t_grid[x][y]); } switch (option) { case PixelRetrievalOptions.RaiseError: throw new ArgumentOutOfRangeException(String.Format("In FluidField.GetFluidAmount(), requested pixel {0}{1} is outside image bounds.", x, y)); case PixelRetrievalOptions.ReturnDefaultBlack: return(0); case PixelRetrievalOptions.ReturnEdgePixel: int tempX = 0, tempY = 0; if (x < 0) { tempX = 0; } if (x >= t_grid.Length) { tempX = t_grid.Length - 1; } if (y < 0) { tempY = 0; } if (y >= t_grid[0].Length) { tempY = t_grid[0].Length - 1; } return(t_grid[tempX][tempY]); default: throw new ArgumentOutOfRangeException(String.Format("In FluidField.GetFluidAmount(), PixelRetrievalOption {0} is not supported.", option.ToString())); } }
public Engine.Color.Cell GetPixel(int x, int y, PixelRetrievalOptions option) { if (x >= 0 && x < Width && y >= 0 && y < Height) { return(new Engine.Color.Cell(t_imageData.Array, t_grid[x][y])); } switch (option) { case PixelRetrievalOptions.RaiseError: throw new ArgumentOutOfRangeException(String.Format("In ImageDataGrid.GetPixel(), requested pixel {0}:{1} is outside image bounds.", x, y)); case PixelRetrievalOptions.ReturnDefaultBlack: return(Engine.Colors.Black); case PixelRetrievalOptions.ReturnNeutralGray: return(Engine.Colors.Gray); case PixelRetrievalOptions.ReturnEdgePixel: int tempX = 0, tempY = 0; if (x < 0) { tempX = 0; } if (x >= Width) { tempX = Width - 1; } if (y < 0) { tempY = 0; } if (y >= Height) { tempY = Height - 1; } return(new Engine.Color.Cell(t_imageData.Array, t_grid[tempX][tempY])); default: throw new ArgumentOutOfRangeException(String.Format("In ImageDataGrid.GetPixel(), PixelRetrievalOption {0} is not supported.", option.ToString())); } }
public byte GetPixel(int x, int y, PixelRetrievalOptions option) { if (x >= 0 && x < Width && y >= 0 && y < Height) { return(t_grid[x][y]); } switch (option) { case PixelRetrievalOptions.RaiseError: throw new ArgumentOutOfRangeException(String.Format("In Mask.GetPixel(), requested pixel {0}:{1} is outside image bounds.", x, y)); case PixelRetrievalOptions.ReturnDefaultBlack: return(0); case PixelRetrievalOptions.ReturnNeutralGray: return(128); case PixelRetrievalOptions.ReturnWhite: return(255); case PixelRetrievalOptions.ReturnEdgePixel: int tempX = 0, tempY = 0; if (x < 0) { tempX = 0; } if (x >= Width) { tempX = Width - 1; } if (y < 0) { tempY = 0; } if (y >= Height) { tempY = Height - 1; } return(t_grid[tempX][tempY]); default: throw new ArgumentOutOfRangeException(String.Format("In Mask.GetPixel(), PixelRetrievalOption {0} is not supported.", option.ToString())); } }