Forums Register Login

Need Help Loading couple images to a BufferedImage.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
 


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.
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1852 times.
Similar Threads
applet in jar does not work
loading an image
image blanks out... why?
Need help on print , scrollbar for my applet
bouncy ball applet image problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:55:43.