public void InvertSelection()
{
int xstart = 0;
int xend = Layers[SelectionLayerIndex].Image.Width;
int ystart = 0;
int yend = Layers[SelectionLayerIndex].Image.Height;
if (!SelectionBounds.IsEmpty)
{
xstart = SelectionBounds.X;
xend = SelectionBounds.X + SelectionBounds.Width;
ystart = SelectionBounds.Y;
yend = SelectionBounds.Y + SelectionBounds.Height;
}
for (int x = xstart; x < xend ; x++)
{
for (int y = ystart; y < yend; y++)
{
if (Layers[SelectionLayerIndex].Image.GetPixel(x, y).ToArgb() == SelectionColor.ToArgb())
Layers[SelectionLayerIndex].Image.SetPixel(x, y, Color.Transparent);
else
Layers[SelectionLayerIndex].Image.SetPixel(x, y, SelectionColor);
}
}
OnSelectionChanged("Invert Selection");
}