Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

I'm 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; it's drawn fine, but it is still anti-aliased.

 

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

 

Here's what I'm using ATM:

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.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted (edited)

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 doesn't 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?

Edited by Bucky

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...