Java Draw Image drawImage(Graphics2D g2d, BufferedImage image, Rectangle dispArea)

Here you can find the source of drawImage(Graphics2D g2d, BufferedImage image, Rectangle dispArea)

Description

draw Image

License

Apache License

Declaration

public static void drawImage(Graphics2D g2d, BufferedImage image, Rectangle dispArea) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.*;
import java.awt.image.*;

public class Main {
    public static void drawImage(Graphics2D g2d, BufferedImage image, Rectangle dispArea) {
        int wt = image.getWidth();
        int ht = image.getHeight();
        int x = dispArea.x + (int) ((dispArea.width - wt) / 2);
        int y = dispArea.y + (int) ((dispArea.height - ht) / 2);
        g2d.drawImage(image, x, y, wt, ht, null);
    }//from w ww .j  a va2  s. c  o m
}

Related

  1. drawImage(BufferedImage target, Point targetPoint, BufferedImage source)
  2. drawImage(final Graphics2D graphics, final Image image, final Rectangle rectangle)
  3. drawImage(Graphics g, BufferedImage im, Rectangle dst, Rectangle src)
  4. drawImage(Graphics graphics, Component comp, Image image)
  5. drawImage(Graphics2D g, BufferedImage image, int x, int y)
  6. drawImage(Image image, Dimension windowSize, Graphics graphics)
  7. drawImage(Image image, Graphics g, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)
  8. drawImage(Image img, double x, double y, Graphics2D graphics)
  9. drawImageClip(Graphics g, BufferedImage image, ImageObserver observer)