public bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y, bool incremental) { if (x == _oldPixel.X && y == _oldPixel.Y) { return(false); } IsPreview = false; Brush brush = Brushes.SelectedBrush; int startX = x - (brush.Width / 2); int startY = y - (brush.Height / 2); for (int ry = 0; ry < brush.Height; ++ry) { for (int rx = 0; rx < brush.Width; ++rx) { int xx = startX + rx; int yy = startY + ry; if (xx < 0 || xx >= skin.Width || yy < 0 || yy >= skin.Height) { continue; } if (brush[rx, ry] == 0.0f) { continue; } ColorPixel c = pixels[xx, yy]; Color oldColor = Color.FromArgb(c.Alpha, c.Red, c.Green, c.Blue); ColorManager.RGBColor color = (((Control.ModifierKeys & Keys.Shift) != 0) ? Editor.MainForm.ColorPanel.UnselectedColor : Editor.MainForm.ColorPanel.SelectedColor).RGB; byte maxAlpha = color.A; var alphaToAdd = (float)(byte)(brush[rx, ry] * 255 * (Editor.MainForm.ColorPanel.SelectedColor.RGB.A / 255.0f)); if (!incremental && _undo.Points.ContainsKey(new Point(xx, yy)) && _undo.Points[new Point(xx, yy)].Item2.TotalAlpha >= maxAlpha) { continue; } if (!incremental && _undo.Points.ContainsKey(new Point(xx, yy)) && _undo.Points[new Point(xx, yy)].Item2.TotalAlpha + alphaToAdd >= maxAlpha) { alphaToAdd = maxAlpha - _undo.Points[new Point(xx, yy)].Item2.TotalAlpha; } color = Color.FromArgb((byte)(alphaToAdd), color); Color newColor = BlendColor(color, oldColor); if (oldColor == newColor) { continue; } if (_undo.Points.ContainsKey(new Point(xx, yy))) { Tuple <Color, ColorAlpha> tupl = _undo.Points[new Point(xx, yy)]; _undo.Points[new Point(xx, yy)] = Tuple.Create(tupl.Item1, new ColorAlpha(newColor, tupl.Item2.TotalAlpha + alphaToAdd)); } else { _undo.Points.Add(new Point(xx, yy), Tuple.Create(oldColor, new ColorAlpha(newColor, alphaToAdd))); } pixels[xx, yy] = new ColorPixel(newColor.R | (newColor.G << 8) | (newColor.B << 16) | (newColor.A << 24)); } } _oldPixel = new Point(x, y); return(true); }