I created a Bitmap
and draw a simple string
and Rectangle
on it. Furthermore I set graphics
's SmoothingMode
to AntiAlias
.
orgBitmap = new Bitmap(250, 250);
using (Graphics graphics = Graphics.FromImage(orgBitmap))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
Rectangle rect = new Rectangle(30, 30, 150, 200);
graphics.FillRectangle(Brushes.Red, rect);
using (Pen pen = new Pen(Color.Green, 5))
{
graphics.DrawRectangle(pen, rect);
}
graphics.DrawString("Test Test Test Test", new Font("Arial", 20, FontStyle.Regular), Brushes.Black, 35, 35);
}
This shows some unexpected behaviour, because not all the graphics have been antialiased. Somehow the antialiasing is limited to all the graphics located in the Rectangles
's area. The string
drawn outside this area did not get antialiased and I wonder why. Is this a bug or how can I fix it?