Show Me The Pixel

M

Martijn Mulder

When I zoom in on an image, GDI+ automatically smoothens the edges
between the pixels. I am looking for a way to see the individual pixels
as squares in the enlarged image, like in MSPaint. I searched in vain in
the enumerations System.Drawing.Drawing2D.SmoothingMode and
System.Drawing.Drawing2D.InterpolationMode to find the constant that
does just that. How?
 
M

Martijn Mulder

Martijn Mulder schreef:
When I zoom in on an image, GDI+ automatically smoothens the edges
between the pixels. I am looking for a way to see the individual pixels
as squares in the enlarged image, like in MSPaint. I searched in vain in
the enumerations System.Drawing.Drawing2D.SmoothingMode and
System.Drawing.Drawing2D.InterpolationMode to find the constant that
does just that. How?

Some code to illustrate the problem:


using System.Drawing;
using System.Windows.Forms;
class MyForm:Form
{
override protected void OnPaint(PaintEventArgs a)
{
Bitmap bitmap=new Bitmap(2,2);
Graphics graphics=Graphics.FromImage(bitmap);
graphics.Clear(Color.Green);
graphics.DrawLine(Pens.Red,1,1,2,2);
graphics.Dispose();
a.Graphics.DrawImage
(
bitmap,
new Rectangle(0,0,200,200),
new Rectangle(0,0,2,2),
GraphicsUnit.Pixel
);
}
[System.STAThread]
static void Main()
{
Application.Run(new MyForm());
}
}
 
P

Peter Duniho

Martijn said:
When I zoom in on an image, GDI+ automatically smoothens the edges
between the pixels. I am looking for a way to see the individual pixels
as squares in the enlarged image, like in MSPaint. I searched in vain in
the enumerations System.Drawing.Drawing2D.SmoothingMode and
System.Drawing.Drawing2D.InterpolationMode to find the constant that
does just that. How?

I don't understand the statement "searched in vain". How did you
search? When I type in "InterpolationMode" into the MSDN web site
search box, this is the first page that is listed in the search results:

http://msdn2.microsoft.com/en-us/library/system.drawing.drawing2d.interpolationmode.aspx

I don't know for sure that any mode will do exactly what you want. But
you might want to try InterpolationMode.NearestNeighbor. That might do it.

Pete
 

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