B4J Question DrawImage and antisliasing

klaus

Expert
Licensed User
Longtime User
It seems that the DrawImage and DrawImage2 methods have an antialiasing included.
Is there a way to remove this.
Attached a small test program.
The first line at the left side is drawn with DrawLine.
Then the image of this line is copied besides the provious line with DrawImage2, we see that the line is blurred.
Then we copy this new line to its right, again with DrawImage2, and the same once more.
We notice that the more we copy the line the more blurred it becomes.

upload_2016-7-14_12-56-44.png
 

Attachments

  • DrawImage.zip
    1.7 KB · Views: 287

Cableguy

Expert
Licensed User
Longtime User
nice finding! I guess there will be cases where the anti-aliasing will come in handy, and some cases where it wont!
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Correct me if I'm wrong, but, won't the anti-aliasing only affect the outer edges of the copied image? (opposed to anti-aliasing every pixel/color)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
... won't the anti-aliasing only affect the outer edges of the copied image?
No. In the test project I have a Canvas with a width of 400 and a height of 250 pixels.
I first draw a line from x0 = 0, y0 = 100 to x1 = 100 and y1 = 200, then I copy the left part of the image containing the line. The copie image has a width = 100 pixels and height = 250 pixels.
The line is in the middle of the height not at an edge. The line has an antialiasing which smoothes the line edges.
But I don't want this.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I found a library that allows you to turn off the antialiasing - only minor code changes required
library from http://www.jfree.org/fxgraphics2d/ (not included here as there may be license restriction)

To be honest I can't see a difference, but then I have bad eyes.
 

Attachments

  • antialias.zip
    2.1 KB · Views: 266
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

klaus

Expert
Licensed User
Longtime User
Are you using non-standard dpi settings?

I used text size 150%.
I set it back to 100% and the lines are sharp.
I set it to 150% again, and now the lines are sharp !!!???
Thank you for the hint !
 
Upvote 0
Top