Java Draw Image drawNormalImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer, int imageWidth, int imageHeight)

Here you can find the source of drawNormalImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer, int imageWidth, int imageHeight)

Description

draw Normal Image

License

Open Source License

Declaration

public static void drawNormalImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer,
            int imageWidth, int imageHeight) 

Method Source Code


//package com.java2s;

import java.awt.Graphics2D;
import java.awt.Image;

import java.awt.geom.Rectangle2D;

import java.awt.image.ImageObserver;

public class Main {
    public static void drawNormalImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer,
            int imageWidth, int imageHeight) {
        int x = (int) bounds.getX();
        int y = (int) bounds.getY();
        int w = Math.min(imageWidth, (int) bounds.getWidth());
        int h = Math.min(imageHeight, (int) bounds.getHeight());

        // no scaling is done here - note it uses only (x, y) coordinates, not width and height
        g2.drawImage(image, x, y, x + w, y + h, 0, 0, w, h, /* g2.getColor(),*/ observer);
    }/*w w  w .  j av  a  2 s .  c  om*/
}

Related

  1. drawImageInRect(Graphics g2d, BufferedImage img, Rectangle rect, double xfactor, double yfactor)
  2. drawImageInRect(Graphics2D gr, Image img, Rectangle r, boolean noShrink)
  3. drawImageWithClipping(Graphics g, BufferedImage img)
  4. drawInMiddle(Graphics g, Image image, String text)
  5. drawLabel(BufferedImage image, String text)
  6. drawOnto(final BufferedImage pDestination, final Image pSource)
  7. drawPixel(BufferedImage img, int x, int y, int color)
  8. drawPixel(int x, int y, Color color, BufferedImage displayMap)
  9. drawScaledImage(Graphics graphics, BufferedImage image, int x, int y, int w, int h, int left, int right)