SmoothingMode should definitely affect your output.
Here are some settings that I recently used to resize an image with minimal loss of quality:
graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
InterpolationMode is probably not suitable for your example, but a PixelOffsetMode may be. Let me deploy a quick test application.
Update: In this quick test application, SmoothingMode definitely affects the lines I draw.
private void Form1_Load(object sender, EventArgs e) { foreach (var value in Enum.GetValues(typeof(SmoothingMode))) { _ComboBoxSmoothingMode.Items.Add(value); } foreach (var value in Enum.GetValues(typeof(PixelOffsetMode))) { _ComboBoxPixelOffsetMode.Items.Add(value); } _ComboBoxPixelOffsetMode.SelectedIndex = 0; _ComboBoxSmoothingMode.SelectedIndex = 0; } private void _ButtonDraw_Click(object sender, EventArgs e) { using (Graphics g = _LabelDrawing.CreateGraphics()) { g.Clear(Color.White); if (_ComboBoxPixelOffsetMode.SelectedItem != null && (PixelOffsetMode)_ComboBoxPixelOffsetMode.SelectedItem != PixelOffsetMode.Invalid) { g.PixelOffsetMode = (PixelOffsetMode)_ComboBoxPixelOffsetMode.SelectedItem; } if (_ComboBoxSmoothingMode.SelectedItem != null && (SmoothingMode)_ComboBoxSmoothingMode.SelectedItem != SmoothingMode.Invalid) { g.SmoothingMode = (SmoothingMode)_ComboBoxSmoothingMode.SelectedItem; } using (Pen pen = new Pen(Color.Blue, 3)) { g.DrawLines(pen, new[] { new Point(0, 0), new Point(25, 50), new Point(_LabelDrawing.Width - 25, _LabelDrawing.Height - 50), new Point(_LabelDrawing.Width, _LabelDrawing.Height), }); } } }
SmoothingMode: AntiAlias None
SmoothingMode.AntiAlias http://www.ccswe.com/temp/SmoothingMode_AntiAlias.png SmoothingMode.None http://www.ccswe.com/temp/SmoothingMode_None.png
Update:. As Morbo remarked, if the Graphics object presented to you in PaintEventArgs is not the same Graphics object that will ultimately be used for display, then anti-aliasing may not have any effect. Although I would not expect such a sharp difference if it were a Graphics object from Image memory or something like that.
I would like to offer more. Perhaps if I had better understood that I was giving you LineShape and your reasoning for using it using only one of the Graphics.DrawLine () methods.
The reason I posed a question about your use of LineShape is because you override it with OnPaint and draw your own line. It looks like you could simplify your application and align LineShape , but maybe I missed something.
Update: Well, that makes sense why you are using LineShape . The only suggestion I can offer at this moment is to override OnPaint in your panel or LineShape, try setting the anti-aliasing mode there before the base event is triggered. Something like:
protected override void OnPaint(PaintEventArgs e) { e.Graphichs.SmoothingMode = SmoothingMode.AntiAlias; base.OnPaint(e); }