Flutter/Dart and AntiAliasing

Viewed 1783

I'm currently programming an indoor navigation app in Flutter and I'm quite new in Flutter and Dart. For this I use and want to extend the library mapsforge_flutter, based on mapsforge for Android. With mapsforge_flutter I can download OpenStreetMap maps, which are rendered on the phone then. The problem ist, that the lines on the maps look quite pixelated like this: enter image description here

AntiAliasing has yet to be implemented in mapsforge_flutter, so I thought the problem may lie there. In the original mapsforge lib, the maps don't look so pixelated.

AA was implemented in the original library in that way:

// in Parameters.java: 

     //If true will use anti-aliasing in rendering.
     public static boolean ANTI_ALIASING = true;

// in AndroidPaint.java:

     AndroidPaint() {
        paint = new android.graphics.Paint();
        this.paint.setAntiAlias(Parameters.ANTI_ALIASING);
        this.paint.setStrokeCap(getAndroidCap(Cap.ROUND));
        this.paint.setStrokeJoin(android.graphics.Paint.Join.ROUND);
        this.paint.setStyle(getAndroidStyle(Style.FILL));
     }

// in AwtCanvas.java:

     AwtCanvas(Graphics2D graphics2D) {
        this.graphics2D = graphics2D;
        setAntiAlias(Parameters.ANTI_ALIASING);
        createFilters();
     }

     public void setBitmap(Bitmap bitmap) {
        if (bitmap == null) {
           this.bufferedImage = null;
           this.graphics2D = null;
        } else {
           this.bufferedImage = AwtGraphicFactory.getBitmap(bitmap);
           this.graphics2D = this.bufferedImage.createGraphics();
           setAntiAlias(Parameters.ANTI_ALIASING);
           this.graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
           this.graphics2D.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
       }
     }

In mapsforge_flutter there are two classes: Mapcanvas and Fluttercanvas with the following methods, that have to be implemented:

// in Fluttercanvas.dart:

bool isAntiAlias() {
// TODO: implement isAntiAlias
return null;
}

@override
void setAntiAlias(bool aa) {
// TODO: implement setAntiAlias
}

// in Mapcanvas.dart:

bool isAntiAlias();

Has anyone an idea, how this can be implemented in Flutter/Dart? The methods from the documentation (https://api.flutter.dev/flutter/dart-ui/Paint/isAntiAlias.html) doesn't seem to work for me.

Thanks in advance!

1 Answers
Related