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:SaveImage.java

public SaveImage() {
    try {/*from w w  w. j a v  a 2s. c om*/
        bi = ImageIO.read(new File("bld.jpg"));
        w = bi.getWidth(null);
        h = bi.getHeight(null);
        if (bi.getType() != BufferedImage.TYPE_INT_RGB) {
            BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics big = bi2.getGraphics();
            big.drawImage(bi, 0, 0, null);
            biFiltered = bi = bi2;
        }
    } catch (IOException e) {
        System.out.println("Image could not be read");
        System.exit(1);
    }
}

From source file:Ventanas.VentanaVerGrafico.java

public void paint(Graphics g) {
    super.paint(g);
    g.translate(getInsets().left, getInsets().top);
    g.drawImage(grafica, 0, 0, this);
}

From source file:test.mandelbrot.MandelbrotApp.java

@Override
public void paint(Graphics g) {
    if (done) {//  w w  w  .  j a  va 2s  .c o  m
        g.drawImage(offscreen, 0, 0, this);
        this.setTitle("Done");
    } else {
        g.drawImage(offscreen, 0, 0, this);
        g.setColor(Color.white);
        g.drawRect(WIDTH / 4, 10, WIDTH / 2, 5);
        g.fillRect(WIDTH / 4, 11, (progress * (WIDTH / 2)) / HEIGHT, 4);
    }
}

From source file:ImageDrawingComponent.java

public ImageDrawingComponent(URL imageSrc) {
    try {//from   w w w  .  j av a  2 s.  co m
        bi = ImageIO.read(imageSrc);
        w = bi.getWidth(null);
        h = bi.getHeight(null);
        if (bi.getType() != BufferedImage.TYPE_INT_RGB) {
            BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics big = bi2.getGraphics();
            big.drawImage(bi, 0, 0, null);
            bi = bi2;
        }
    } catch (IOException e) {
        System.out.println("Image could not be read");
        System.exit(1);
    }
}

From source file:org.optaplanner.examples.coachshuttlegathering.swingui.CoachShuttleGatheringWorldPanel.java

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (canvas != null) {
        g.drawImage(canvas, 0, 0, this);
    }/*from w  ww.  ja  v  a2  s  .  c o m*/
}

From source file:org.pentaho.ui.xul.swing.tags.SwingVbox.java

public SwingVbox(Element self, XulComponent parent, XulDomContainer domContainer, String tagName) {
    super("Vbox");
    this.domContainer = domContainer;
    this.orientation = Orient.VERTICAL;

    container = new ScrollablePanel(new GridBagLayout()) {

        @Override/* ww  w.  j  av a  2s . c o  m*/
        public void paintComponent(Graphics g) {
            if (backgroundImage != null) {
                g.drawImage(backgroundImage, 0, 0, container);
            }
        }

    };
    container.setOpaque(false);
    setManagedObject(container);
    setPadding(2);

}

From source file:test.uk.co.modularaudio.util.audio.gui.buffervis.BufferVisualiser.java

@Override
public void paint(final Graphics g) {
    if (bi != null) {
        g.drawImage(bi, 0, 0, null);
    }
}

From source file:com.geometrycloud.happydonut.swing.ImagePanel.java

@Override
public void paint(Graphics g) {
    super.paint(g);
    if (null != image) {
        g.drawImage(image, 0, 0, this);
    }//from   w w  w. j  a va2 s .  c o m
}

From source file:test.mandelbrot.SequentialMandelbrotApp.java

@Override
public synchronized void paint(Graphics g) {
    if (done) {//from w w  w .j a v  a 2  s .  co m
        g.drawImage(offscreen, 0, 0, this);
        this.setTitle("Done");
    } else {
        g.drawImage(offscreen, 0, 0, this);
        g.setColor(Color.white);
        g.drawRect(WIDTH / 4, 10, WIDTH / 2, 5);
        g.fillRect(WIDTH / 4, 11, (progress * (WIDTH / 2)) / HEIGHT, 4);
    }
}

From source file:GrabandFadewithRasters.java

public void paint(Graphics g) {
    int value;//  w  ww.java2 s .  com
    int sourceRed, sourceGreen, sourceBlue;
    if (newImage != null) {
        g.drawImage(newImage, 0, 0, this);
        if (imageLoaded == false) {
            imageLoaded = true;
            for (int x = 0; x < width; x += 1)
                for (int y = 0; y < height; y += 1) {
                    value = originalPixelArray[x * height + y];
                    sourceRed = raster.getSample(x, y, 1);
                    sourceGreen = raster.getSample(x, y, 2);
                    sourceBlue = raster.getSample(x, y, 3);

                    if (sourceRed > index) {
                        sourceRed -= index;
                        imageLoaded = false;
                    } else
                        sourceRed = 0;

                    if (sourceGreen > index) {
                        sourceGreen -= index;
                        imageLoaded = false;
                    } else
                        sourceGreen = 0;

                    if (sourceBlue > index) {
                        sourceBlue -= index;
                        imageLoaded = false;
                    } else
                        sourceBlue = 0;

                    raster.setSample(x, y, 1, sourceRed);
                    raster.setSample(x, y, 2, sourceGreen);
                    raster.setSample(x, y, 3, sourceBlue);
                }
            mis.newPixels();
        }
    }
}