aspose file tools*
The moose likes Applets and the fly likes Need Help Loading couple images to a BufferedImage. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Need Help Loading couple images to a BufferedImage." Watch "Need Help Loading couple images to a BufferedImage." New topic
Author

Need Help Loading couple images to a BufferedImage.

Shika San
Greenhorn

Joined: Nov 26, 2011
Posts: 2
Greetings EveryOne

I am making a board game, I want to load the board and the pieces with their current locations into a BufferedImage then paint the BufferedImage to the screen, is this a good aproch? if not can you show me a better one?

Here is the code that I came up with:



The output is a 50*50 black square, the image doesn't shows up, even it's in the same directory as the applet.

Please SomeOne Help, Thank You.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

Hi Shika and welcome to the Ranch! First off, please learn to follow coding conventions. Your variable names should start with a lowercase letter.

You have created a BufferedImage of size 50 X 50 pixels. Then you draw another image to its Graphics context, starting at the coordinate [50, 50]. This places the drawn image outside the image it is being drawn to, so it's not surprising that you don't see anything. You need to read the API for the constructors and methods used -- guesswork seldom pays off in programming.

Also note that setSize is not the correct way to size an Applet; that's taken care of in the HTML tag that displays an Applet. and once you get past the basics, you'll likely want to move away from the hugely dated java.awt.Applet to the newer javax.swing.JApplet, when you'll need to learn how custom painting is correctly done in Swing.


luck, db
There are no new questions, but there may be new answers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

Also, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/java-2d/51824-need-help-loading-couple-images-bufferedimage.html
Shika San
Greenhorn

Joined: Nov 26, 2011
Posts: 2

You have created a BufferedImage of size 50 X 50 pixels. Then you draw another image to its Graphics context, starting at the coordinate [50, 50]. This places the drawn image outside the image it is being drawn to, so it's not surprising that you don't see anything.


Thank you for your reply.

I have tried what you suggested but the result is the same:



Maybe that's not what you have suggested, but that's what I have understood, Thank You.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help Loading couple images to a BufferedImage.