Michael Rettkowitz

Michael Rettkowitz

  • NA
  • 39
  • 18.5k

GDI+ - how can I deactivate antialiasing?

Nov 29 2010 2:18 AM

Hi,
if using the code below to fill an area on a bitmap...
 

Dim ImgBg As Bitmap = System.Drawing.Bitmap.FromFile(Filename1)
ImgBg.SetResolution(72, 72)
Dim g As Graphics = Graphics.FromImage(ImgBg)
g.SmoothingMode = Drawing2D.SmoothingMode.None
Dim mybrush As Brush = Brushes.Beige
g.FillRectangle(mybrush, rect)
g.Dispose()
ImgBg.Save(
Filename2)

also the pixels around the 'rect' area are manipulated, but they should remain, as they are.
The same effect I'm having, when inserting images using g.DrawImage(...), g.DrawImageUnscaled(...), g.DrawImageUnscaledAndClipped(...)
Does anyone know, how to prevent this?
Michael

Answers (1)