In my application I noticed some image artifacts. I found that the problem is that DrawImage degrades the image at each drawing. When I draw an image over a transparent image the pixel color changes a little bit. If I draw it multiple times the pixel color keeps degrading. You can see in the attached example that the color values (RGB) reach from 29 to 15 after a few draws. I tried different properties of the Graphics (InterpolationMode, PixelOffsetMode, SmoothingMode, CompositingQuality) but the result was the same. Does any of you know a solution for this problem?
public static void Main(string[] args)
{
Bitmap bmporig = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
bmporig.SetPixel(0, 0, Color.FromArgb(247, 29, 29, 29));
Bitmap bmp = null;
for (int i = 0; i < 15; i++)
{
bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
Graphics gr = Graphics.FromImage(bmp);
gr.DrawImage(bmporig, 0, 0);
bmporig = bmp;
}
System.Drawing.Color col = bmp.GetPixel(0,0);
Console.WriteLine(col.A.ToString() + "," + col.R.ToString() + "," + col.G.ToString() + "," + col.B.ToString());
}