static final BufferedImage getScaledImage(BufferedImage src, int newWidth,
			int newHeight) {
		if (src == null) {
			return null;
		}
		if (newWidth == 0 && newHeight == 0)
			return null;
		BufferedImage scaledImage = new BufferedImage(newWidth, newHeight,
				BufferedImage.TYPE_INT_RGB);
		;
		int w = src.getWidth();
		int h = src.getHeight();
		if ((w == newWidth && h == newHeight)) {
			// no scaling needed, just return a copy
			scaledImage.setRGB(0, 0, w, h, src.getRGB(0, 0, w, h, null, 0, w),
					0, w);
		} else // scale image
		{
			Graphics2D graphics2D = scaledImage.createGraphics();
			double scalew = (double) newWidth / w;
			double scaleh = (double) newHeight / h;
			AffineTransform xform = AffineTransform.getScaleInstance(scalew,
					scaleh);
			graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,

			RenderingHints.VALUE_INTERPOLATION_BICUBIC);
			graphics2D.drawImage(src, xform, null);
			graphics2D.dispose();
		}
		return scaledImage;
	}