List of usage examples for java.awt Graphics drawImage
public abstract boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer);
From source file:Main.java
@Override protected void paintComponent(Graphics g) { g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), null); }
From source file:Main.java
public void paint(Graphics g) { g.drawImage(bi, 0, 0, getWidth(), getHeight(), this); }
From source file:Main.java
public void paint(Graphics g) { g.drawImage(pic, 0, 0, getWidth(), getHeight(), this); }
From source file:Main.java
public void paint(Graphics g) { Image img = createImage(); g.drawImage(img, 20, 20, 400, 400, this); }
From source file:MemImage.java
public void paint(Graphics g) { g.drawImage(img, 0, 0, getSize().width, getSize().height, this); }
From source file:Main.java
@Override public void paintComponent(Graphics g) { super.paintComponent(g); if (image != null) { g.drawImage(image, 0, 0, getWidth(), getHeight(), null); }//from w w w.j a v a 2 s. co m }
From source file:interactivespaces.service.image.vision.opencv.swing.OpenCvMatPanel.java
@Override public void paintComponent(Graphics g) { if (image != null) { g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), this); }//from ww w . j av a2s . c o m }
From source file:gr.iti.mklab.reveal.forensics.util.Util.java
public static BufferedImage scaleImage(BufferedImage image, int width, int height) { assert (width > 0 && height > 0); // create image of new size BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = img.getGraphics(); ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); // ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g.drawImage(image, 0, 0, img.getWidth(), img.getHeight(), null); return img;// w w w .java 2s . co m }
From source file:ScalingMethods.java
/** * Draws the picture five times, using the five different scaling * approaches described in the book. All five look the same, since * all are using default (nearest neighbor) filtering during the * scale operation./*from w w w . j av a 2 s . co m*/ */ public void paintComponent(Graphics g) { int x = PADDING; int y = PADDING; // Simplest approach g.drawImage(picture, x, y, scaleW, scaleH, null); // Subregion approach x += scaleW + PADDING; g.drawImage(picture, x, y, x + scaleW, y + scaleH, 0, 0, picture.getWidth(), picture.getHeight(), null); // Graphics2D.scale approach x += scaleW + PADDING; Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x, y); g2d.scale(SCALE_FACTOR, SCALE_FACTOR); g2d.drawImage(picture, 0, 0, null); g2d.dispose(); // AffineTransform.scale approach x += scaleW + PADDING; g2d = (Graphics2D) g.create(); AffineTransform at = new AffineTransform(); at.translate(x, y); at.scale(SCALE_FACTOR, SCALE_FACTOR); g2d.drawImage(picture, at, null); g2d.dispose(); // getScaledInstance() approach x += scaleW + PADDING; Image scaledImg = picture.getScaledInstance(scaleW, scaleH, Image.SCALE_DEFAULT); g.drawImage(scaledImg, x, y, null); }
From source file:MouseDrag.java
public void paint(Graphics g) { int w = curX - startX, h = curY - startY; Dimension d = getSize();/* w w w . j a v a 2 s .c o m*/ g.drawImage(curImage, 0, 0, d.width, d.height, this); if (startX < 0 || startY < 0) return; System.err.println("paint:drawRect @[" + startX + "," + startY + "] size " + w + "x" + h); g.setColor(Color.red); g.fillRect(startX, startY, w, h); }