6

I'm try to improve some of the drawing that I'm doing in my project by provide antialiasing. I'm playing with a simple project using the Graphics32 Library instead of the standard delphi Canvas functions. I am testing with simple shapes and noticed a blurring affect and was wondering if it could be fixed.

procedure TForm1.FormPaint(Sender: TObject);
var
    Points : TArrayOfFixedPoint;
    ar: array [0 .. 6] of Tpoint;
begin
    // Antialiased Triangle
    SetLength(Points, 3);
    Points[0] := FixedPoint(20, 20);
    Points[1] := FixedPoint(20 + 100, 20 + 20);
    Points[2] := FixedPoint(20, 20 + 20);
    PolygonFS(self.mBitmap, FixedPointToFloatPoint(Points), clYellow32, pfAlternate, nil); // Draw Filled Polygon
    PolylineFS(self.mBitmap, FixedPointToFloatPoint(Points), clBlack32, true, 1); // Draw Outline

    self.mBitmap.DrawTo(self.Canvas.Handle, 0, 0);

    // Normal Triangle
    ar[0] := point(20, 150);
    ar[1] := point(20 + 100, 150 + 20);
    ar[2] := point(20, 150 + 20);
    ar[3] := point(20, 150);
    self.Canvas.Brush.Color := clYellow;
    self.Canvas.Polygon(slice(ar, 3));
end;

The antialiased triangle has a much smoother hypotenuse, but the two straight lines looks like they're blurred, which makes sense since it's antialiased. Is there a way to get the best of both worlds where the vertical and horizontal lines don't blend, while smoothing out the hypotenuse?

Edit: The version of Graphic32 I'm using is the top of the master branch from the Official Github Fork since the last release appears to be 1.9.1 from 2012.

Clayton Johnson
  • 279
  • 4
  • 16
  • Obviously you *could* by drawing the centre as you do, then draw the hypotenuse aliased and the other two sides normally, using MoveTo/LineTo. But I am not convinced that this is the best of both worlds, even in this special case, because two line would look sharp and one fuzzy. Surely it is best for all 3 to be fuzzy? – Dsm Nov 21 '16 at 08:26
  • @Dsm I have been thinking that drawing the lines individually would achieve the result I think I was looking for. I'll have to make an example later to see what it looks like – Clayton Johnson Nov 21 '16 at 08:35
  • 2
    Have you tried playing with `TAntialiasMode`? I recall there are overloaded methods where you can specify `aaMode`. You did not say which version of GR32 you are using, so I can't say if it applies to your project.You could ofcourse also provide the missing parts of your test to make it more easy for those that would take the time to try and help you. In other words a [MCVE](http://stackoverflow.com/help/mcve). – Tom Brunberg Nov 21 '16 at 11:16
  • @TomBrunberg I've updated the question to include information about which version of Graphics32 I'm using. Would these be the overloads you were talking about [link](http://graphics32.org/documentation/Docs/Units/GR32_Polygons/Routines/Polygon.htm) I can't find these in the source itself (GR32_Polygons), but I may be looking in the wrong unit – Clayton Johnson Nov 22 '16 at 00:23
  • Good news: Graphics32 has been updated last month (04.2017) – Gabriel May 11 '17 at 10:52
  • @BorlImpriceGoGearEmbaIdera cheers for that, I'll have to take a look and see what's changed – Clayton Johnson May 12 '17 at 02:29
  • @ClaytonJohnson - not much. just some bugs fixed. make sure you donwnload from github and not from sourceforge! – Gabriel May 12 '17 at 11:42

0 Answers0