code: public static BufferedImage createCompatibleImage(BufferedImage image,
                                                        int width, int height) {
          return isHeadless() ?
                  new BufferedImage(width, height, image.getType()) :
                  getGraphicsConfiguration().createCompatibleImage(width, height,
                                                     image.getTransparency());
      }
docs: <p>Returns a new compatible image of the specified width and height, and
  the same transparency setting as the image specified as a parameter.
  That is, the returned <code>BufferedImage</code> is compatible with
  the graphics hardware. If the method is called in a headless
  environment, then the returned BufferedImage will be compatible with
  the source image.</p>
  
  @see java.awt.Transparency
  @see #createCompatibleImage(java.awt.image.BufferedImage)
  @see #createCompatibleImage(int, int)
  @see #createCompatibleTranslucentImage(int, int)
  @see #loadCompatibleImage(java.net.URL)
  @see #toCompatibleImage(java.awt.image.BufferedImage)
  @param width the width of the new image
  @param height the height of the new image
  @param image the reference image from which the transparency of the new
  image is obtained
  @return a new compatible <code>BufferedImage</code> with the same
  transparency as <code>image</code> and the specified dimension