Java Draw Image drawOnto(final BufferedImage pDestination, final Image pSource)

Here you can find the source of drawOnto(final BufferedImage pDestination, final Image pSource)

Description

Draws the source image onto the buffered image, using AlphaComposite.Src and coordinates 0, 0 .

License

Open Source License

Parameter

Parameter Description
pDestination the image to draw on
pSource the source image to draw

Exception

Parameter Description
NullPointerException if pDestination or pSource is null

Declaration

static void drawOnto(final BufferedImage pDestination, final Image pSource) 

Method Source Code


//package com.java2s;
import java.awt.*;

import java.awt.image.*;

public class Main {
    /**// w  w w  .  ja  v a2 s. c  om
     * Draws the source image onto the buffered image, using
     * {@code AlphaComposite.Src} and coordinates {@code 0, 0}.
     *
     * @param pDestination the image to draw on
     * @param pSource the source image to draw
     *
     * @throws NullPointerException if {@code pDestination} or {@code pSource} is {@code null}
     */
    static void drawOnto(final BufferedImage pDestination, final Image pSource) {
        Graphics2D g = pDestination.createGraphics();
        try {
            g.setComposite(AlphaComposite.Src);
            g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
            g.drawImage(pSource, 0, 0, null);
        } finally {
            g.dispose();
        }
    }
}

Related

  1. drawImageInRect(Graphics2D gr, Image img, Rectangle r, boolean noShrink)
  2. drawImageWithClipping(Graphics g, BufferedImage img)
  3. drawInMiddle(Graphics g, Image image, String text)
  4. drawLabel(BufferedImage image, String text)
  5. drawNormalImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer, int imageWidth, int imageHeight)
  6. drawPixel(BufferedImage img, int x, int y, int color)
  7. drawPixel(int x, int y, Color color, BufferedImage displayMap)
  8. drawScaledImage(Graphics graphics, BufferedImage image, int x, int y, int w, int h, int left, int right)
  9. drawScaledImage(Image image, Component canvas, Graphics g)