This project is read-only.

antialiasing on rotated rasters

Sep 14, 2012 at 11:30 PM
Edited Sep 14, 2012 at 11:30 PM


Whenever I rotate a raster, a .bgd more precisely, an anti-aliasing (or some sort of smoothing) is applied.

The code below does nothing:

map1.Layers.MapFrame.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

I don't know this is related, but if I open the bgd file with MapWindowGIS three new files are created:

- a .bmp (I understand DotSpatial creates this same bmp, but on memory, as InRamImage, Am I right?)

- a bpw (a world file)

- a mwleg that is a xml file that controls the smoothing on MapWindowGIS, below I copy the line that do the control:

 ImageUpsamplingMethod="None" ImageDownsamplingMethod="None">

If ImageUpsamplingMethod is set to "Bilinear" instead of "None" the smoothing occurs

Also I've tried to modify the painting event with the following:

map1.Paint += NoSmooth;

private void NoSmooth(object sender, PaintEventArgs e)
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
            e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;

but without success unfortunately

Any hint or suggestion on how to cancel the smoothing  will be greatly appreciated


Sep 17, 2012 at 5:33 PM


Sep 19, 2012 at 6:33 PM


I could notice that there are a lot of requests for help without any reply on this forum. This is very unfortunate. I know this is an open source project, so it's expected for the users to find their own way at some point. Nonetheless, no open source project goes far if the questions posted get no reply at all. I'd like to ask to the main developers to spend a bit more of time on this forum helping the users. GIS software is complicated, and the DotSpatial API is a very good example of this, yet this nice library, and their developers, shouldn't have this "elitist" attitude (if you let me use this word).

To get rid of the smoothing go to the InRamImage class (DotSpatial source) and add the following to the GetBitmap method (the first one):

g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;

Sep 20, 2012 at 4:27 PM

Osito, I'm glad you found DotSpatial to be useful and have made some good progress on using it in your project. Please know that no one on the project (that I know of) is "elitist". We are all just voluntarily building and sharing this code. No one is getting rich of this. Please continue to help provide feedback to others and of course we'd be glad to have you help fix bugs and contribute to the project more as your time and commitments allow. - Dan