Java Draw Image drawImage(Image img, double x, double y, Graphics2D graphics)

Here you can find the source of drawImage(Image img, double x, double y, Graphics2D graphics)

Description

Draws an entire image (full size) at the specified coordinates.

License

Open Source License

Declaration

public static Graphics2D drawImage(Image img, double x, double y, Graphics2D graphics) 

Method Source Code


//package com.java2s;
import java.awt.Graphics2D;
import java.awt.Image;

public class Main {
    /**/*w  w  w .  j a  v a  2  s.  com*/
     * Draws an entire image (full size) at the specified coordinates.
     */
    public static Graphics2D drawImage(Image img, double x, double y, Graphics2D graphics) {
        graphics.drawImage(img, round(x), round(y), null);
        return graphics;
    }

    /**
     * Draws an entire image (full size) at the specified coordinates.
     */
    public static Graphics2D drawImage(Image img, double x, double y, double w, double h, Graphics2D graphics) {
        graphics.drawImage(img, round(x), round(y), round(w), round(h), null);
        return graphics;
    }

    private static int round(double val) {
        return (int) Math.round(val);
    }
}

Related

  1. drawImage(Graphics graphics, Component comp, Image image)
  2. drawImage(Graphics2D g, BufferedImage image, int x, int y)
  3. drawImage(Graphics2D g2d, BufferedImage image, Rectangle dispArea)
  4. drawImage(Image image, Dimension windowSize, Graphics graphics)
  5. drawImage(Image image, Graphics g, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)
  6. drawImageClip(Graphics g, BufferedImage image, ImageObserver observer)
  7. drawImageInOval(Graphics2D gr, Image img, Rectangle r, boolean noShrink)
  8. drawImageInPolygon(Graphics g2d, BufferedImage img, Polygon poly, double xfactor, double yfactor)
  9. drawImageInRect(Graphics g2d, BufferedImage img, Rectangle rect, double xfactor, double yfactor)