public void SetBrightness(int brightness) { imageHandler.RestorePrevious(); if (brightness < -255) brightness = -255; if (brightness > 255) brightness = 255; ColorMatrix cMatrix = new ColorMatrix(CurrentColorMatrix.Array); cMatrix.Matrix40 = cMatrix.Matrix41 = cMatrix.Matrix42 = brightness / 255.0F; imageHandler.ProcessBitmap(cMatrix); } internal void ProcessBitmap(ColorMatrix colorMatrix) { Bitmap bmap = new Bitmap(_currentBitmap.Width, _currentBitmap.Height) ImageAttributes imgAttributes = new ImageAttributes(); imgAttributes.SetColorMatrix(colorMatrix); Graphics g = Graphics.FromImage(bmap); g.InterpolationMode = InterpolationMode.NearestNeighbor; g.DrawImage(_currentBitmap, new Rectangle(0, 0, _currentBitmap.Width, _currentBitmap.Height), 0, 0, _currentBitmap.Width, _currentBitmap.Height, GraphicsUnit.Pixel, imgAttributes); _currentBitmap = (Bitmap)bmap.Clone(); }
new Bitmap
bmap.Clone
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)