java - draw image or draw filled circle? -


we have old java swing application. need display thousands, hundreds of thousands small circle spots on canvas based on real data. right have image file of small circle spot. when need it, draw image onto canvas, thousands, hundreds of thousands times.

now think may better (better performance , memory usage) draw filled circle each time instead of load image , draw it.

how opinion?

thanks,

you need load template image once , hold in memory , copy canvas needed using graphics2d drawimage function. drawing multiple filled circles may become expensive due calls flood-fill/scan-fill algorithm bresenham draw circle. optimize rendering can decimate rendered result or perform clustering, since user not appreciate dense overlapping circles anyway.

to reduce render calls test pixel template going , pass render if coloured.

here nice benchmarking applet.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -