title: Fastest method for blurring an image in java
body: <p><strong>Edit</strong> I'm using Eclipse ADT bundle but when I try importing the library in the suggested answer above it doesn't work.</p>
  
  <p>I'm using a combination of LibGDX and Java (90-99% java) to blur an image. The blur works but it takes nearly a second to take a screenshot, save it, access it, blur it, save it, and re-access it. I can't do much pre-processing because it takes a screenshot of the game to blur. Here is what I'm using currently for blurring: (I'll put drawing and screenshots up if you need to see them, but I think the issue lies in the blurring of an 800x480 png.)</p>
  
  <pre><code>import java.awt.image.BufferedImage;
  import java.awt.image.BufferedImageOp;
  import java.awt.image.ConvolveOp;
  import java.awt.image.Kernel;
  import java.io.File;
  import java.io.IOException;
  
  import javax.imageio.ImageIO;
  
  import com.badlogic.gdx.Gdx;
  import com.badlogic.gdx.files.FileHandle;
  
  
  public class Blur {
      private static BufferedImage mshi;
      private BufferedImage databuf;
      private static int blurRad = 300;
  
      public static void createBlur(FileHandle file) throws IOException {
          mshi = ImageIO.read(file.file());
          BufferedImage databuf = new BufferedImage(mshi.getWidth(null),
                  mshi.getHeight(null),
                  BufferedImage.TYPE_INT_BGR);
  
          java.awt.Graphics g = databuf.getGraphics();
          g.drawImage(mshi, 455, 255, null);
  
          float[] blurKernel = new float[blurRad*blurRad];
          for(int i =0; i&lt;blurRad*blurRad; i++) {
              blurKernel[i] = 1.0f/256.0f;
          }
  
          BufferedImageOp op = new ConvolveOp( new Kernel(20, 20, blurKernel), ConvolveOp.EDGE_ZERO_FILL, null );
          mshi = op.filter(mshi, databuf);
  
          g.dispose();    
  
          File outputfile = Gdx.files.local("Blur.png").file();
          ImageIO.write(mshi, "png", outputfile);
      }
  }
  </code></pre>