title: Image Resampling Bicubic Interpolation Java
body: <p>I have resized image but its quality is low. i heard of bicubic interpolation but i cant get any implementation code. Here is my code:</p>
  
  <pre><code>private static BufferedImage resize(BufferedImage image, int width, int height) 
  { 
      int w = image.getWidth(), h = image.getHeight();
      int type = image.getType() == 0? BufferedImage.TYPE_INT_ARGB : image.getType();
      BufferedImage resizedImage = new BufferedImage(width, height, type);
      Graphics2D g = resizedImage.createGraphics();
      g.setComposite(AlphaComposite.Src);
      g.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
      g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
  
      //g.drawImage(image, 0, 0, width, height, null);
      g.scale((double)width/w,(double)height/h);
      g.drawRenderedImage(image, null);
      g.dispose();
      return resizedImage; 
  }   
  </code></pre>
  
  <p>I want to get the best quality after upsampling and downsampling.</p>