javagraphics2dgaussianblur

In-built method/flag for applying gaussian blur to objects drawn by Graphics2D?


Are there any in-built methods, or flags I can set, with a Java Graphics2D object such that I can draw polygons or other shapes with gaussian blur automatically applied?

Or if anyone knows of a computationally efficient shortcut/hack, that would be greatly appreciated.


Solution

  • AFAIK - no.

    Most blur operations operate on a BufferedImage as they need to manipulate the underlying pixel data. A typical approach is to render the content to an image, blur it, then paint that to whatever you want

    I prefer to use JHLabs filters generally, they're not the fastest, but generally give a high quality result.

    This example is a little involved, but demonstrates the basic idea.

    As another example and if your really want to make your eyes bleed ;)