protected override void DoPreprocessing(FastBitmap bmp) { for (int y = 0; y < bmp.height; ++y) { for (int x = 0; x < bmp.width; ++x) { Color color = bmp.GetPixel(x, y); rMult += color.R; gMult += color.G; bMult += color.B; } } int pixelCount = bmp.height * bmp.width; rMult /= pixelCount; gMult /= pixelCount; bMult /= pixelCount; float avg = (rMult + gMult + bMult) / 3; rMult = avg / rMult; gMult = avg / gMult; bMult = avg / bMult; /// Normalizing multipliers float max = rMult; if (gMult > max) { max = gMult; } if (bMult > max) { max = bMult; } rMult /= max; gMult /= max; bMult /= max; }
public mainForm() { InitializeComponent(); bmp = new FastBitmap(pictureBox.Width, pictureBox.Height); changeFiltersEnabled(true); }
protected override void DoPreprocessing(FastBitmap bmp) { xBase = bmp.width / 2; yBase = bmp.height / 2; }
protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y) { Color source = bmp.GetPixel(x, y); return(Color.FromArgb((int)(source.R * rMult), (int)(source.G * gMult), (int)(source.B * bMult))); }
protected virtual void DoPreprocessing(FastBitmap bmp) { return; }
protected abstract Color CalculateNewPixelColor(FastBitmap bmp, int x, int y);
protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y) { throw new NotImplementedException(); }
protected override Color CalculateNewPixelColor(FastBitmap bmp, int x, int y) { Color source = bmp.GetPixel(x, y); return(Color.FromArgb(255 - source.R, 255 - source.G, 255 - source.B)); }