0

Javaでロードされた画像にいくつかのフィルターを適用するアプリケーションを作成しています..

互換性のあるバッファリングされた画像を作成し、graphics2d オブジェクトを取得して、新しい画像をレンダリングするところに行き詰まっています。

これは、互換性のある BufferedImage を作成する私のコードです。

pbi=obi.getSubimage(0, 0, obi.getWidth(),obi.getHeight());
            int altoImagen=pbi.getHeight();
            int anchoImagen=pbi.getWidth();
            pbi=new BufferedImage(anchoImagen,altoImagen,BufferedImage.TYPE_INT_RGB);
            g2=pbi.createGraphics();

その後、元の画像でObi OriginalBufferedImageにフィルターを適用します..

float ninth=1.0f/9.0f;
        float[]blurKernel={
            ninth,ninth,ninth,
            ninth,ninth,ninth,
            ninth,ninth,ninth
        };
        ConvolveOp op=new ConvolveOp(new Kernel(3,3,blurKernel));
        obi=op.filter(obi,null);    
        lienzo.repaint();
        g2.drawImage(obi, null,null);

問題は、新しい画像がレンダリングされていないことです..

私がしたときにそれが起こったと思いますg2=pbi.createGraphics..しかし、多くのチュートリアルでは、そのステップを実行する必要があります..

誰かがレンダリングがどのように機能するかを正確に説明できますか..

私はコンポーネントを使用していません。代わりに Graphics2d.drawImage() を使用して画像 (およびグラフィックス) を JPanel にレンダリングしています。

4

0 に答える 0