IIRC you need to specify the PixelFormat in the bitmap constructor.
Maybe you can find the answer in the source code of this CodeProject article:
For text antialiasing play around with values in Graphics.TextRenderingHint. I'd advise not to use ClearType, because that will only show up nice on LCD monitors (not CRT), and might not work due to the rotation.
P.S. It's Vilx-, not Vlix. :D
It turns out that Microsoft have a new dynamic image library for the web as part of the Asp.Net content on CodePlex:
http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449
Unfortunately it's a little bit much for what I want. Using unsafe code I can roll my own alpha transparency, but that's far too slow given this code's use as part of a high-usage web application.
Is this just a bug in MS's GDI+ .Net implementation?
You should at least specify a 32bits pixel format (ex: PixelFormat.Format32bppArgb) when creating your bitmap, otherwise GDI+ cannot manage transparency.
To tune the resulting file when saving, you can use Save with ImageCodecInfo and EncoderParameters.
Sorry, I didn't read your question carefully enough.
I know that I have successfully drawn rotated text on a colored background without seeing either of the aliasing effects in your examples. When I went back to look at my code, I realized that I was drawing the rotated text using a logical font, which is nicely wrapped in the Microsoft.WindowsCE.Forms namespace. This technique sets the drawing angle as a property of the logical font (so you don't call TranslateTransform or RotateTransform).
Outside of the Windows CE world, you have to PInvoke to create a logical font (I've never done this and I couldn't find a good example quickly). I don't know how well this would perform, but I know for sure that it will draw rotated text without the weird aliasing effects you're seeing. I think for sure this is a bug in GDI+ (or just something they didn't think anyone would ever really use).
An alternative approach that might even perform better than the logical font is to draw the text normally on a colored rectangle background (just large enough to hold the text), then rotate-and-copy the rectangle onto your main image. Graphics.DrawImage doesn't appear to be able to do rotation, but this effect is easy to implement using LockBits.
Or, you could just render the text to a non-transparent PNG, but use a background color (instead of white) that matches the background color of the cell.
Hi,
To fix the text "blockiness", can't you just do...
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
after this line...
Graphics g = Graphics.FromImage( (Image) image );