Disable anti-alaised painting in Paint event

Bucky

Well-known member
Joined
Dec 23, 2001
Messages
791
Location
East Coast
User Rank
*Expert*
Im trying to resize an image and paint it in a PictureBox in its
Paint event, but the picture is supposed to be drawn regularly,
not anti-aliased. Setting the SmoothingMode property to None
has no effect; its drawn fine, but it is still anti-aliased.

How can I have it painted regularly, but still scaled up?

Heres what Im using ATM:
C#:
private void pic_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
	Graphics g = e.Graphics;
	g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

	Rectangle dest = new Rectangle(xOffset * scale * -1, yOffset * scale * -1, bmp.Width * scale, bmp.Height * scale); // these are all form-level variables
	g.DrawImage(bmp, dest); // bmp is a form-level variable
}

Thanks.
 
Have you tried fiddling with CompositingMode, CompositingQuality and InterpolationMode?
 
No such luck. In fact, I just realized that I cannot even change the
properties of the Graphics object. Whenever I assign a value, the
property doesnt even change to the value I try to assign to it.
I had forgotten that e.Graphics is a read-only object.

So, I take it I need to do the painting somewhere else, or find a
way to alter the e.Graphics object. Which of these should I do,
and how?
 
Last edited by a moderator:
Back
Top