1

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.

HomerPlata
  • 1,687
  • 5
  • 22
  • 39
  • AFAIK - no. Most blur operations operate on a BufferedImage as they need to manipulate the underlying pixel data. A typical approach is to renderer the content to an image, blur it, then paint that to what ever you want – MadProgrammer Apr 03 '17 at 09:35
  • I prefer [jhlabs](http://www.jhlabs.com/ip/blurring.html), not the fastest, but among the simplest and gives good quality – MadProgrammer Apr 03 '17 at 09:37
  • [This is involved answer](http://stackoverflow.com/questions/34123731/add-glow-to-a-basic-java-rectangle/34124063#34124063) but has a fast blur – MadProgrammer Apr 03 '17 at 09:40
  • [And other example](http://stackoverflow.com/questions/23215415/create-an-transparent-rectangle-over-blurred-background-in-jframe/23232618#23232618) – MadProgrammer Apr 03 '17 at 09:49
  • [And if you want to make your eyes bleed](https://github.com/RustyKnight/BlurPane) – MadProgrammer Apr 03 '17 at 09:56
  • Wow, thanks man. You've given me more than enough for an accepted answer there. If you want to stick any of those comments in an answer, I'll accept it. Tar. – HomerPlata Apr 03 '17 at 10:00

1 Answers1

1

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, there 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 ;)

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366