简体   繁体   中英

How to program anti-aliasing in Java

I have implement the Bresenham Algorithm for a Simple line drwaing class, and now i want to set a anti-aliasing over it, I use JavaFX for the viewing.

How can i implement a anti-aliasing without using library´s ?

One way to do anti-aliasing is to use oversampling. The image is rendered in a higher solution, where typically for efficiency and ease of implementation the generated image is larger by a factor which is a power of two. The resulting image is then downsampled.

A more efficient way (which has some drawbacks on the other hand) is the algorithm by Wu . In this approach, a lookup table is used which stores the desired coloring for adjacent pixels in which a pixel is plotted using sub-pixel accuracy. Bresenham's line algorithm then uses this lookup table to place a pixel with actual sub-pixel accuracy.

The latter approach does not require downsampling and potentially fewer memory accesses, however atrifacts might show up if lines cross as the second line cancels out the pixels plotted for the first line. This effeced can be remedied by using saturated addition for the pixels instead of replacement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM