GDI+ Poor Quality when rotating pictures

02-18-2005, 07:06 AM

i modified an existing GDI+ example to do rotation to pictures.
If i rotate an example picture four times for 90 degress the result is much worse than the beginning.
I attached a demo project. Press four times the rotate button an then the reset button to see the difference, or do rotation much more.
I need a possibility to rotate pictures without loss of quality e.g. to switch a photogtraph from landscape to portrait.

Thanks in Advance

Thank you for your help with GDI+.
Where can i get some information about using the GDI-Functions ?

02-18-2005, 08:45 AM
The loss of quality is from constantly creating and destroying the bitmap. I would change your routines to accept a bitmap class instance as a parameter. The graphics class can be created and destroyed without any problem.

Also, use Bitmap.RotateFlip for various rotations of 90/180/270 degrees, instead of RotateTransform.

I don't see any code to Set gdip = Nothing, this is usually done in the form_unload event.

MS has very little about GDI+ flat posted. What little they do have is for C++:

02-18-2005, 08:50 AM
I should also mention, Graphics.SetInterpolationMode with InterpolationModeHighQualityBilinear or InterpolationModeHighQualityBicubic will increase the quality with which images are drawn by DrawImage.

02-18-2005, 08:35 PM
A common mistake people make is to rotate an already rotated image.
Each time you rotate, artifacts are introduced into the resulting picture. Each further
rotation will degrade the image further. The proper way is to keep the original picture
intact and rotate the original image to the accumulated angle, i.e. if you rotate the
image 10 degrees, 3 times, you rotate the original image by 10 degrees, then you
rotate the original image by 20 degrees, and then the original by 30 degrees. Always
start with a clean original, or the image will eventually dissolve into soup.

02-19-2005, 12:49 AM
Good point passel. And that's exactly what he was seeing in drawing and recreating from the drawn image. I didn't do that in my original example.

Luckily, the bitmap RotateFlip is on the original bitmap and should be lossless.

02-20-2005, 12:48 PM
I need a possibility to rotate pictures without loss of quality e.g. to switch a photogtraph from landscape to portrait.

If you want to rotate photos (from digital cameras) in JPEG format have a look here:

02-21-2005, 03:47 AM

I know that it is better to rotate for 180 degrees once than two times for 90 degrees !!!
I modified in this way to demonstrate HOW bad the loss of quality is !

If you do only one rotation of 90 degrees you probably won't see the loss of quality with your eyes.

Now i tested the RotateFlip-Command and this worked fine.
Even if i do 4 times 90 degrees !!!


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum