I am trying to XOR some values ββwith the RGB values ββof my image, save this image and take steps back to get the original image. The problem is that I do not know why I get an incomprehensible (with some noise) image. Here is my code and 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 saving the image, I change
Bitmap inp_bmp = new Bitmap("D:\\img\\1.jpg");
for
Bitmap inp_bmp = new Bitmap("D:\\img\\4.jpg");
and delete
//inp_bmp.Save("D:\\img\\4.jpg");
and I get an image like

(left original, right - the result); As you can see, I get the wrong colors in Figure 4, why? In general, he is close to the original, but still he is wrong
source share