public void editImage(Bitmap imageToEdit) { var rectangle = new Rectangle(0, 0, imageToEdit.Width, imageToEdit.Height); var data = imageToEdit.LockBits(rectangle, System.Drawing.Imaging.ImageLockMode.ReadWrite, imageToEdit.PixelFormat); var depth = Bitmap.GetPixelFormatSize(data.PixelFormat) / bitsInByte; var buffer = new byte[data.Width * data.Height * depth]; System.Runtime.InteropServices.Marshal.Copy(data.Scan0, buffer, 0, buffer.Length); this.threadsCount = 2; Thread GaussianBlurThread1 = new Thread(() => processImage(buffer, offset, offset, imageToEdit.Width - offset, imageToEdit.Height / threadsCount, imageToEdit.Width, depth)); Thread GaussianBlurThread2 = new Thread(() => processImage(buffer, offset, imageToEdit.Height / threadsCount, imageToEdit.Width - offset, imageToEdit.Height - offset, imageToEdit.Width, depth)); GaussianBlurThread1.Start(); GaussianBlurThread2.Start(); GaussianBlurThread1.Join(); GaussianBlurThread2.Join(); System.Runtime.InteropServices.Marshal.Copy(buffer, 0, data.Scan0, buffer.Length); imageToEdit.UnlockBits(data); UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { Color pixel; for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); int ColoredPixelR = 0; int ColoredPixelG = 0; int ColoredPixelB = 0; switch (colorOption) { case (int)colors.Red: { ColoredPixelR = pixel.R; ColoredPixelG = pixel.G - maxRGBValue; ColoredPixelB = pixel.B - maxRGBValue; break; } case (int)colors.Green: { ColoredPixelR = pixel.R - maxRGBValue; ColoredPixelG = pixel.G; ColoredPixelB = pixel.B - maxRGBValue; break; } case (int)colors.Blue: { ColoredPixelR = pixel.R - maxRGBValue; ColoredPixelG = pixel.G - maxRGBValue; ColoredPixelB = pixel.B; break; } } ColoredPixelR = Math.Max(ColoredPixelR, minRGBValue); ColoredPixelR = Math.Min(maxRGBValue, ColoredPixelR); ColoredPixelG = Math.Max(ColoredPixelG, minRGBValue); ColoredPixelG = Math.Min(maxRGBValue, ColoredPixelG); ColoredPixelB = Math.Max(ColoredPixelB, minRGBValue); ColoredPixelB = Math.Min(maxRGBValue, ColoredPixelB); imageToEdit.SetPixel(i, j, Color.FromArgb(ColoredPixelR, ColoredPixelG, ColoredPixelB)); } } UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { makeBrightenPixelsList(); Color pixel; for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); imageToEdit.SetPixel(i, j, Color.FromArgb(brightenPixels[pixel.R], brightenPixels[pixel.G], brightenPixels[pixel.B])); } } UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { makeGammaPixelsList(); Color pixel; for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); imageToEdit.SetPixel(i, j, Color.FromArgb(pixelsAfterGammaCorrection[pixel.R], pixelsAfterGammaCorrection[pixel.G], pixelsAfterGammaCorrection[pixel.B])); } } UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { Color pixel; for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); var NegativePixelR = maxRGBValue - pixel.R; var NegativePixelG = maxRGBValue - pixel.G; var NegativePixelB = maxRGBValue - pixel.B; imageToEdit.SetPixel(i, j, Color.FromArgb(NegativePixelR, NegativePixelG, NegativePixelB)); } } UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { makeGraynessPixelsLists(); Color pixel; for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); int newPixelValue = graynessRPixels[pixel.R] + graynessGPixels[pixel.G] + graynessBPixels[pixel.B]; imageToEdit.SetPixel(i, j, Color.FromArgb(newPixelValue, newPixelValue, newPixelValue)); } } UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { Color pixel; int SepiaPixelR = 0; int SepiaPixelG = 0; int SepiaPixelB = 0; for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); SepiaPixelR = (int)(0.393 * pixel.R + 0.769 * pixel.G + 0.189 * pixel.B); SepiaPixelG = (int)(0.349 * pixel.R + 0.686 * pixel.G + 0.168 * pixel.B); SepiaPixelB = (int)(0.272 * pixel.R + 0.534 * pixel.G + 0.131 * pixel.B); if (SepiaPixelR > maxRGBValue) { SepiaPixelR = maxRGBValue; } if (SepiaPixelG > maxRGBValue) { SepiaPixelG = maxRGBValue; } if (SepiaPixelB > maxRGBValue) { SepiaPixelB = maxRGBValue; } imageToEdit.SetPixel(i, j, Color.FromArgb(SepiaPixelR, SepiaPixelG, SepiaPixelB)); } } UsersImage.saveEditedImage(imageToEdit); }
public void editImage(Bitmap imageToEdit) { Color pixel; findMinMaxValuesOfComponentsInImage(imageToEdit, out int minRValue, out int maxRValue, out int minGValue, out int maxGValue, out int minBValue, out int maxBValue); this.LUT_R = makeLUTArray(minRValue, maxRValue); this.LUT_G = makeLUTArray(minGValue, maxGValue); this.LUT_B = makeLUTArray(minBValue, maxBValue); for (int i = 0; i < imageToEdit.Width; ++i) { for (int j = 0; j < imageToEdit.Height; ++j) { pixel = imageToEdit.GetPixel(i, j); imageToEdit.SetPixel(i, j, Color.FromArgb((int)LUT_R[pixel.R], (int)LUT_G[pixel.G], (int)LUT_B[pixel.B])); } } UsersImage.saveEditedImage(imageToEdit); }