Example usage for java.awt Graphics drawImage

List of usage examples for java.awt Graphics drawImage

Introduction

In this page you can find the example usage for java.awt Graphics drawImage.

Prototype

public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer);

Source Link

Document

Draws as much of the specified image as is currently available.

Usage

From source file:ImageBorderHack.java

public BufferedImage createBufferedImage(Image img) {
    BufferedImage buff = new BufferedImage(img.getWidth(null), img.getHeight(null),
            BufferedImage.TYPE_INT_ARGB);
    Graphics gfx = buff.createGraphics();
    gfx.drawImage(img, 0, 0, null);
    gfx.dispose();//w  w  w  .  j a v a2s.c o m
    return buff;
}

From source file:test.buddhabrot.BuddhabrotApp.java

@Override
public synchronized void paint(Graphics g) {
    g.drawImage(image, 0, 0, this);
}

From source file:Scale.java

public void paint(Graphics g) {
    super.paint(g);
    if (insets == null) {
        insets = getInsets();/*from  ww  w  .  ja va2 s . co  m*/
    }
    g.drawImage(image, insets.left, insets.top, this);
}

From source file:ScrollPaneWatermark.java

public void paintChildren(Graphics g) {
    super.paintChildren(g);
    if (fgimage != null) {
        g.drawImage(fgimage, getWidth() - fgimage.getWidth(null), 0, null);
    }//w w  w .ja va 2s. com
}

From source file:ThumbnailTools.java

/**
 * Save the thumbnail to the specified file, with the specified type
 * @param file the file//ww  w  .  j a  va  2s .c o m
 * @param imageType the image type
 */
public void saveThumbnail(File file, String imageType) {
    if (thumb != null) {
        BufferedImage bi = new BufferedImage(thumb.getIconWidth(), thumb.getIconHeight(),
                BufferedImage.TYPE_INT_RGB);
        Graphics g = bi.getGraphics();
        g.drawImage(thumb.getImage(), 0, 0, null);
        try {
            ImageIO.write(bi, imageType, file);
        } catch (IOException ioe) {
            throw new RuntimeException("Error occured saving thumbnail");
        }
    } else {
        throw new RuntimeException("Thumbnail have to be created before.");
    }
}

From source file:Main.java

protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    int imwidth = bgimage.getWidth(null);
    int imheight = bgimage.getHeight(null);
    g.drawImage(bgimage, 1, 1, null);
}

From source file:DrawingApplet.java

public void paint(Graphics g) {
    g.drawImage(image, 0, 0, this);
}

From source file:Main.java

protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    int x = 0;/*www . j ava 2 s. c om*/
    int y = 0;
    for (int i = 0; i < imgs.length; i++) {
        g.drawImage(imgs[i], x, y, null);
        x += imgs[i].getWidth(null);
    }
}

From source file:MainClass.java

public void paint(Graphics g) {
    NegativeFilter nf = new NegativeFilter();

    Image i = createImage(new FilteredImageSource(createImage().getSource(), nf));

    g.drawImage(i, 20, 20, this);
}

From source file:neembuu.uploader.captcha.ImagePanel.java

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    //int x = this.getWidth()/4;
    g.drawImage(image, 10, 10, null); // see javadoc for more info on the parameters            
}