public static Bitmap ToBitmap(PixelImage image) { if (image == null) { throw new ArgumentNullException("image"); } Bitmap bitmap = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb); for (int i = 0; i < image.pixels.Length; i++) { bitmap.SetPixel(i % image.Width, i / image.Width, Color.FromArgb(0, image.pixels[i].R, image.pixels[i].G, image.pixels[i].B)); } return(bitmap); }
public static void BackAndWhite(PixelImage image) { for (int i = 0; i < image.pixels.Length; i++) { if ((image.pixels[i].R + image.pixels[i].G + image.pixels[i].B) / 3 > 127) { image.pixels[i].R = 255; image.pixels[i].G = 255; image.pixels[i].B = 255; } else { image.pixels[i].R = 0; image.pixels[i].G = 0; image.pixels[i].B = 0; } } }
private void SetImage(PixelImage newImage) { this.pixels = newImage.pixels; this.Width = newImage.Width; this.Height = newImage.Height; }