import java.awt.geom.*; static void paintSkyBackground(Component c, Graphics _g, BufferedImage image) { Graphics2D g = cast _g; RenderingHints hints = g.getRenderingHints(); antiAliasOn(g); int w = c.getWidth(), h = c.getHeight(); int iw = image.getWidth(), ih = image.getHeight(); g.setColor(c.getBackground()); g.fillRect(0, 0, w, h); double imgScale = doubleRatio(w, iw); AffineTransform before = g.getTransform(); double y1 = h-ih*imgScale; g.translate(0, y1); g.scale(imgScale, imgScale); g.drawImage(image, 0, 0, c); g.setTransform(before); g.setRenderingHints(hints); }