• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Graphics interpolation issue

brainleak

Well-known member
Joined
Dec 20, 2016
Messages
54
Location
Barcelona area
Programming Experience
3-5
I'm using 2 pictureboxes, one with a source image and the other to zoom in on an area inside a navigation rectangle. I'm using DrawImage to magnify the image (image on the right)

In the source image there is some text added with a graphics program. This text looks bad on the zoomed image due to interpolation. However, when I used StretchBlt with an old VB6 version of the application it looked OK (image on the left).

Is there a way to "worsen the interpolation" to get a similar quality for the .Net version still using the graphics class? I don't care that much about the overall quality of the rest of the image.

VB6.jpgNet.jpg
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,254
Location
Norway
Programming Experience
10+
If the source image is the same (quality) then the worse zoom is due to the Graphics.DrawImage. Graphics class has a small number of properties that could affect quality, you can try changing them to see if zoom improves. See documentation here and click "properties" in navigation to see the relevant properties you can modify: Graphics Class (System.Drawing) | Microsoft Docs
 

brainleak

Well-known member
Joined
Dec 20, 2016
Messages
54
Location
Barcelona area
Programming Experience
3-5
If the source image is the same (quality) then the worse zoom is due to the Graphics.DrawImage. Graphics class has a small number of properties that could affect quality, you can try changing them to see if zoom improves. See documentation here and click "properties" in navigation to see the relevant properties you can modify: Graphics Class (System.Drawing) | Microsoft Docs
Hi, I've spent the last few weeks in a hospital and finally I'm discharged.

Getting back to my problem I have tried these properties (one at a time),

Graphics.CompositingQuality
Graphics.PixelOffsetMode
Graphics.SmoothingMode
Graphics.TextContrast
Graphics.TextRenderingHint

with different values but the result was always the same.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,254
Location
Norway
Programming Experience
10+
Why not set them all? That's what I usually do, I find the documentation is not clear about when each property has a meaning.
You also said "worsen the interpolation", but it sounds to me you should try the high quality settings to not see so much distortion when zoomed.
 

brainleak

Well-known member
Joined
Dec 20, 2016
Messages
54
Location
Barcelona area
Programming Experience
3-5
Why not set them all? That's what I usually do, I find the documentation is not clear about when each property has a meaning.
You also said "worsen the interpolation", but it sounds to me you should try the high quality settings to not see so much distortion when zoomed.
I have used all of them and tried various combinations of values, but I hardly see any change. Maybe there's a specific combintion of parameters for what I'm trying to achieve but I have the feeling I am going nowhere by fooling around with it.
Perhaps I should go back to Bilblt.
 

VicJ

Well-known member
Joined
Aug 12, 2008
Messages
79
Programming Experience
5-10
Use InterpolationMode. None of the modes you listed are relevant to your question. TextRenderingHint might have been if you were using Graphics.DrawString, but it doesn't apply to DrawImage. The mode you need for resizing an image (e.g. with DrawImage) is Graphics.InterpolationMode. The "best" results are usually achieved with the Bicubic interpolation mode, but sometimes Bilenear produces better results. I doubt if there will be a visible difference in your present example.

Personally, I'm against setting all the Graphics modes regardless of what you need. It's better to learn what each one does and use it only when appropriate.

Vic
 
Top Bottom