I'm using the J开发者_C百科AI library to do adjustments on a series of images, each about 1300x1000 in size. I adjust pixel intensities with "Rescale" and add text and lines with the Graphics2D object from the TiledImage.createGraphics() method. Then I resize the image to fit the screen with "subsampleaverage" and render to screen with Graphics2D.drawRenderedImage(). Up to this point, there is little slowdown, with rendering taking about 40-60 milliseconds.
However, if I only add the text and lines, the display slows down to 100-200 milliseconds. I can't seem to figure out why this is, as adding the text after or before adjust pixel intensities is fine.
I've been searching through the site, but I can't seem to find any concrete answer. Many suggestions have been to use BufferedImages, but converting from PlanarImages to BufferedImages seems to also have a slowdown issue.
Apparently text is still rendered very slowly in Java. The glyphs for each Font
object has to be rendered and painted on the Graphics
object. With a lot of text on the object, the Font
object along with all the used Glyphs
are recreated, causing a massive slowdown.
Even using JOGL, there is a significant slowdown. But using the same TextRenderer
object alleviates this by creating a single Font
object and reusing it as long as the TextRenderer
is alive. Of course, this restricts you from using multiple Font objects, as JOGL has yet to implement a setFont
function, requiring you to create a new TextRenderer
object for each new font, font style, and font weight.
Hope this helps anyone with similar issues.
精彩评论