Anti-Aliasing in Graphics.DrawImage()

C

Chris Morse

Hi,

I'm trying to create a little program that loads a 1bpp bitmap
(black/white) and displays it in a PictureBox using the PictureBox's
Paint event. I have buttons for zooming in/out and I calculate the
source image origin rectangle and the destination rectangle.

Problem is that the image should look "blocky" when I zoom in,
but instead it looks *very* anti-aliased.

I tried using this:

'Render Graphics
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None
e.Graphics.DrawImage(m_GraphImage, RD, RS, GraphicsUnit.Pixel)

and it didn't help matters at all..
(where RD = Destination Rect, RS = Source Rect)

Anyone know how to turn off this (default) anti-aliasing behaviour?

I would think that the SmoothingMode would fix it!

Thanks for any pointers!

// CHRIS
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Chris Morse) scripsit:
I'm trying to create a little program that loads a 1bpp bitmap
(black/white) and displays it in a PictureBox using the PictureBox's
Paint event. I have buttons for zooming in/out and I calculate the
source image origin rectangle and the destination rectangle.

Problem is that the image should look "blocky" when I zoom in,
but instead it looks *very* anti-aliased.

I tried using this:

'Render Graphics
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None
e.Graphics.DrawImage(m_GraphImage, RD, RS, GraphicsUnit.Pixel)

and it didn't help matters at all..
(where RD = Destination Rect, RS = Source Rect)

Does this sample work?

<http://www.mvps.org/dotnet/dotnet/code/controls/index.html#bkm4>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top