Good day. There is a code that combines two images into one:

Bitmap bmp1 = new Bitmap("iphone.jpg"); OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { int bmp1_width = bmp1.Width; int bmp1_height = bmp1.Height; Bitmap bmp2 = new Bitmap(dialog.FileName); Bitmap final_bmp = new Bitmap(bmp1_width, bmp1_height); pictureBox1.Image = final_bmp; Graphics g = Graphics.FromImage(final_bmp); g.DrawImage(bmp1, 0, 0, bmp1_width, bmp1_height); g.DrawImage(bmp2, 24, 103, 242, 342); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.Dispose(); pictureBox1.Invalidate(); final_bmp.Save("D:\\output1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } 

Is it possible to somehow save this generalized image, so that in the end it would have the highest possible quality?

enter image description here

If you look closely, you yourself can see that all sorts of small squares and the like are displayed. In the original image there is no such thing.

1 answer 1

 using (Bitmap bmp1 = new Bitmap(@"C:\TestPhoto.jpg")) { ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg); myEncoderParameter = new EncoderParameter(myEncoder, 0L);//вот этот 0L можешь заменить на 100L - это измениние уровня компрессии myEncoderParameters.Param[0] = myEncoderParameter; bmp1.Save(@"C:\TestPhotoQualityZero.jpg", jpgEncoder, myEncoderParameters); } 

Better save to .png