System.Drawing - bad text rendering using DrawString on top of transparent pixels?

The first output is what you get when you draw black text on a black background, probably Color.Transparent. The 2nd was drawn on an almost-black background. The 3rd was drawn on the same background it is being displayed with Anti-aliasing cannot work when on a transparent background.

The colors used for the anti-aliasing pixels will not blend the letter shape into the background when the text is displayed with a different background. Those pixels will now become very noticeable and make the text look very bad Note that SmoothingMode doesn't affect text output. It will look slightly less bad if you use a lower quality TextRenderingnt and a background color that's grayish with a alpha of zero.

Only TextRendering SingleBitPerPixelGridFit avoids all anti-aliasing troubles Getting a perfect fix for this is very difficult. Vista's glass effect on the window title bar uses very subtle shading to give the text a well defined background color. You'd need SysInternals' ZoomIt tool to see it.

Never seen anybody do this themselves.

The first output is what you get when you draw black text on a black background, probably Color.Transparent. The 2nd was drawn on an almost-black background. The 3rd was drawn on the same background it is being displayed with.

Anti-aliasing cannot work when on a transparent background. The colors used for the anti-aliasing pixels will not blend the letter shape into the background when the text is displayed with a different background. Those pixels will now become very noticeable and make the text look very bad.

Note that SmoothingMode doesn't affect text output. It will look slightly less bad if you use a lower quality TextRenderingnt and a background color that's grayish with a alpha of zero. Only TextRenderingSingleBitPerPixelGridFit avoids all anti-aliasing troubles.

Getting a perfect fix for this is very difficult. Vista's glass effect on the window title bar uses very subtle shading to give the text a well defined background color. You'd need SysInternals' ZoomIt tool to see it.

Never seen anybody do this themselves.

Ugh. I suppose I could draw black text onto white on a temporary bitmap, convert white to transparent, and grey to semi-transparent black, then draw this to the final bitmap. I'll try different TextRenderingOtherwise, I think the effect with partial background transparency isn't too bad.

One thing though - in each case, the background is the same color (off-white) with different transparency, so I wouldnt expect text to draw like this with an 'effective' background color of black. – mackenir Jun 7 '10 at 21:51 Not sure what you mean. Key problem is the GDI cannot see the transparency, it sees the RGB value of the transparent color.Color.

Transparent is a very bad choice, its RGB value is zero.Black. – Hans Passant Jun 7 '10 at 22:33 What I mean is the background is painted with off-white, with an alpha component. Not sure where you got Color.

Transparent from. – mackenir Jun 8 '10 at 9:44 @mack: is any of this helpful or shall I just delete my post? – Hans Passant Jun 8 '10 at 11:28 2 You accepted it, then downvoted it.

That's insane. Please remove the answer mark. – Hans Passant Jan 19 at 12:32.

The option I used to workaround this problem was: Graphics graphics = new Graphics(); graphics. TextRenderingDrawing.Text. TextRenderingSingleBitPerPixelGridFit; There are some others useful options in TextRendering.

The first output is what you get when you draw black text on a black background, probably Color.Transparent. The 2nd was drawn on an almost-black background. The 3rd was drawn on the same background it is being displayed with.

Anti-aliasing cannot work when on a transparent background. The colors used for the anti-aliasing pixels will not blend the letter shape into the background when the text is displayed with a different background. Those pixels will now become very noticeable and make the text look very bad.

Note that SmoothingMode doesn't affect text output. It will look slightly less bad if you use a lower quality TextRenderingHint and a background color that's grayish with a alpha of zero. SingleBitPerPixelGridFit avoids all anti-aliasing troubles.

Getting a perfect fix for this is very difficult. Vista's glass effect on the window title bar uses very subtle shading to give the text a well defined background color. You'd need SysInternals' ZoomIt tool to really see it.

DrawThemeTextEx() function with a non-zero iGlowSize.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions