如何在 Java 中的 Graphics2D 中使用高斯模糊绘制背景

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

我尝试了几种方法,但它们都太慢了,我尝试使用 LWJGL 和 LibGdx,但这对我来说太高级了,因为必须使用着色器语言创建着色器。我最后一次尝试失败了,因为速度太慢,而且有故障。这是我尝试的最后一种方法:(我使用 Graphics2D 复合,以及 JHLabs FilterComposite 和 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);
    }

LibGDX(左下第 7 个选项)这里有高斯模糊的实时网络演示 https://crashinvaders.github.io/gdx-vfx/

要在您的应用中加入 GDX-VFX 的详细信息,请点击此处 https://github.com/crashinvaders/gdx-vfx