DrawImage « Graphics « Java Swing Q&A





1. drawImage Java api    stackoverflow.com

drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) I would like to specify a null colour for bg colour in the above method. It defaults to black. I thought ...

3. DrawImage Question    coderanch.com

I'm trying to center one image (the 'f' suffix below) onto another background image (the 'b' suffix below). gOut.drawImage(imageFore, ((heightB + heightf)/2), ((widthB - widthf)/2), ((widthB - widthf)/2), ((heightB - heightf)/2), Color.red, null); My confusion is what do the coordinates mean. The above code is from the drawImage form: public boolean drawImage(Image img, int x, inty, int width, int height) The ...

4. how to use drawImage in an object    coderanch.com

/* * use: appletviewer DrawingImages.java */ import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class DrawingImages extends Applet { public void init() { setLayout(new BorderLayout()); add(new ImageDrawingPanel()); } public static void main(String[] qrgs) { Applet applet = new DrawingImages(); Frame f = new Frame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.add(applet); f.setSize(400,400); f.setLocation(200,200); ...

6. Question about drawimage    coderanch.com

import java.awt.*; import java.awt.geom.AffineTransform; import javax.swing.*; public class DrawingAnImage extends JPanel { Image image; Rectangle rect; public DrawingAnImage() { String path = "images/cougar.jpg"; image = new ImageIcon(getClass().getResource(path)).getImage(); rect = new Rectangle(100, 50, 140, 250); } protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); double iw = image.getWidth(this); double ih = image.getHeight(this); AffineTransform at = new ...

7. Question about drawImage    coderanch.com

8. Question about drawImage on jdk1.6.0    coderanch.com

9. Incremental drawImage()???    coderanch.com





10. Where is drawImage(...) ?    coderanch.com

We extend Graphics2D internally in a private class (called SunGraphics2D, for the curious); that's where all of the real stuff happens. You might think about delegating to Graphics2D for all of the real functionality - that would allow you to specialize things as necessary and then defer to Sun's implementation to do the heavy lifting. Chet.

11. drawImage() problem    coderanch.com

Trying to load an image from file and draw it in a JPanel. Just seems to draw a black rectangle instead of the image. It's a gray scale image, so I thought I could use BufferedImage.TYPE_BYTE_GRAY, i'm not going to be working in color anyway. I will just be lowering the gray scale value from 256 down and evaluating image quality. ...

12. DrawImage with transparency ?    java-forums.org

import java.awt.Graphics; import java.awt.Window; import java.lang.reflect.Method; import javax.swing.ImageIcon; import javax.swing.JWindow; @SuppressWarnings("serial") public class JIcon extends JWindow { public ImageIcon iconImg; public JIcon(ImageIcon icon, float transLvl) { this.iconImg = icon; this.setSize(icon.getIconWidth(),icon.getIconHeight()); try { Class awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities"); Method method = awtUtilitiesClass.getMethod("setWindowOpacity", Window.class, float.class); method.invoke(null, this, transLvl); } catch (Exception exc) { exc.printStackTrace(); } this.setVisible(true); } public void paint(Graphics g) { g.drawImage(iconImg.getImage(),0,0,this); } ...