Beispiel #1
0
        //convert the image to grayscale
        private void convertToGrayscaleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BitmapHelper ctImage = new BitmapHelper(ref img);
            Pixel pixel, tmp=new Pixel(0, 0, 0 );

            for (int i = 0; i < ctImage.getHeight(); i++)
            {
                for (int j = 0; j < ctImage.getWidth(); j++)
                {
                    pixel = ctImage.getPixel(i, j);
                    tmp.Blue=tmp.Green = tmp.Red = Convert.ToInt32(pixel.Red * 0.299 + pixel.Green * 0.587 + pixel.Blue * 0.114);

                    ctImage.setPixel(i, j, tmp);
                }
            }

            img = ctImage.getBitmap();
            origImg.Dispose();
            origImg = new Bitmap(img);
            pictureBox.Image = img;
        }
Beispiel #2
0
        //make the image negative ( 255- R/G/B for each pixel )
        private void negativeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BitmapHelper ctImage = new BitmapHelper(ref img);
            Pixel pixel;

            for (int i = 0; i < ctImage.getHeight(); i++)
            {
                for (int j = 0; j < ctImage.getWidth(); j++)
                {
                    pixel = ctImage.getPixel(i, j);
                    pixel.Red = 255 - pixel.Red;
                    pixel.Green = 255 - pixel.Green;
                    pixel.Blue = 255 - pixel.Blue;
                    ctImage.setPixel(i, j, pixel);
                }
            }

            img = ctImage.getBitmap();
            origImg.Dispose();
            origImg = new Bitmap(img);
            pictureBox.Image = img;
        }