I am trying to XOR some values with RGB values of my image, save that image and to do back steps, to get an original image. The problem is, that I don't know why I get not clear (with some noise) image. Here is my code, and an image below:
Bitmap original = new Bitmap("D:\\img\\1.jpg");
Bitmap inp_bmp = new Bitmap("D:\\img\\1.jpg");
int width = inp_bmp.Width;
int height = inp_bmp.Height;
Color pixel;
for (int y = 0; y < height; y += 1)
{
for (int x = 0; x < width; x += 1)
{
pixel = inp_bmp.GetPixel(x, y);
int a = pixel.A;
int r = (pixel.R ^ (1000))%256;
int g = (pixel.G ^ (185675))%256;
int b = (pixel.B ^ (78942))%256;
inp_bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
}
}
pictureBox2.Image = inp_bmp;
pictureBox1.Image = original;
inp_bmp.Save("D:\\img\\4.jpg");
After an image has been saved, I change
Bitmap inp_bmp = new Bitmap("D:\\img\\1.jpg");
for
Bitmap inp_bmp = new Bitmap("D:\\img\\4.jpg");
and remove
//inp_bmp.Save("D:\\img\\4.jpg");
and I get an image like
(left original, right - result); As you can see, I get some wrong colors at picture 4, why? All in all it is close to original, but still it's not right
Okey, I found the problem. The problem was with saving an image.
This helped:
inp_bmp.Save("D:\\img\\4.png", System.Drawing.Imaging.ImageFormat.Png);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With