簡體   English   中英

如何在 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);
    }

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

要在您的應用程序中包含 GDX-VFX 的詳細信息,請在此處https://github.com/crashinvaders/gdx-vfx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM