I use System.Drawing to create some on-the-fly images that include the base image plus some stretched / scaled text. Everything is fine and neat in my LOCALHOST environment, but when I publish on my server (Server 2008), I lose some anti-aliasing and the image quality becomes grainy.
Here is an example copied from my local environment (Windows 7) and then from my server (Server 2008)
Windows 7:

Windows 2008:

As you can see, the images are the same size and the fonts are scaled the same way. The server version does not seem to have anti-aliasing to smooth the edges. Here is the main code snippet: imgSign and grSign are the installed Image and Graphics object with the given background size / color on which you want to scale / draw the text.
'Requested size of test Dim textSize As SizeF = grSign.MeasureString(textString, font) Dim intTextWidth As Integer = textSize.Width Dim intTextHeight As Integer = textSize.Height 'Create image to hold text Dim img As Drawing.Image = New Bitmap(intTextWidth, intTextHeight) Dim gr As Graphics = Graphics.FromImage(img) 'Smoothing mode gr.SmoothingMode = Drawing2D.SmoothingMode.HighQuality gr.TextRenderingHint = Text.TextRenderingHint.AntiAlias 'Scale Text Dim sngScaleWidth As Single = imgSign.Width / intTextWidth If sngScaleWidth > 1 Then sngScaleWidth = 1 'Don't scale down width if it doesn't need to be Dim sngScaleHeight As Single = imgSign.Height / intTextHeight grSign.ScaleTransform(sngScaleWidth, sngScaleHeight) 'Draw text gr.DrawString(textString, font, Brushes.White, 0, 0)
Is there some kind of functionality that is not on server 2008 that I have to get around, or a switch that I can set to improve quality, or do I need to look elsewhere?
source share