javagraphics2dgaussianblur

How can I draw the background with gaussian blur in Graphics2D in Java


I tried several things but they were all too slow, and I tried to use LWJGL and LibGdx but that's too advanced for me because the shaders must be created in the shader language. The last I tried has failed due to be too slow, and being glitchy. This is the last method I tried: (I used Graphics2D composite, and JHLabs FilterComposite with GaussianBlurFilter)

    public void render(BubbleBlaster game, Graphics2D gg) {
        LoadedGame loadedGame = BubbleBlaster.getInstance().getLoadedGame();
        if (loadedGame == null) {
            return;
        }

        Composite oldCompositeCo = gg.getComposite();
        FilterComposite filterComposite = new FilterComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f), new GaussianBlurFilter(10));

        gg.setComposite(filterComposite);
    }

Solution

  • There is a live web demo of Gaussian Blur for LibGDX (7th option down on the left) here https://crashinvaders.github.io/gdx-vfx/

    To include in your app details of GDX-VFX are here https://github.com/crashinvaders/gdx-vfx.