Results 1 to 3 of 3
- 05-03-2012, 04:28 AM #1
Member
- Join Date
- May 2012
- Posts
- 1
- Rep Power
- 0
Having issues with drawing portion of an image
I am having issues with trying to draw a section of an image with my Frame, it is able to draw the whole image but when I try to do a section I see nothing being drawn on the screen.
RPConsole.pngJava Code:package TestConsole; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class AwtImage extends Frame { Image img; BufferedImage characters; public static void main(String[] args) throws IOException { AwtImage ai = new AwtImage(); } public AwtImage() throws IOException { super("Image Frame"); MediaTracker mt = new MediaTracker(this); img = ImageIO.read(this.getClass().getResource("RPConsole.png")); characters = ImageIO.read(this.getClass().getResource("RPChars.png")); mt.addImage(img, 0); //mt.addImage(characters, 1); setSize(356, 258); setVisible(true); setResizable(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { dispose(); } }); } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { if (img != null) { g.drawImage(img, 3, 25, this); g.drawImage(characters, 15, 15, 19, 19, 15, 15, 19, 19, this); } else g.clearRect(0, 0, getSize().width, getSize().height); } }
RPChars.png
- 05-03-2012, 06:49 AM #2
Re: Having issues with drawing portion of an image
How big a part of that second image (in pixels X pixels) do you think you're drawing, and where?
Do you have a reason for using the archaic AWT and not Swing, which supplanted it more than 10 years ago?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-03-2012, 06:50 AM #3
Similar Threads
-
Having issues drawing Shapes into Jpanel
By Greedychris in forum AWT / SwingReplies: 2Last Post: 03-06-2012, 05:32 AM -
Image issues
By Toll in forum Advanced JavaReplies: 7Last Post: 05-20-2011, 04:38 AM -
Printing portion of an image
By thayalan in forum AWT / SwingReplies: 0Last Post: 07-06-2009, 02:04 AM -
Problems drawing a section of an image onto another image.
By Cain in forum Java 2DReplies: 1Last Post: 04-17-2009, 12:44 AM -
drawing an image to an offscreen image
By hunterbdb in forum Java 2DReplies: 9Last Post: 10-30-2008, 06:17 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks