This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Game Development and the fly likes UTFDataFormatException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "UTFDataFormatException" Watch "UTFDataFormatException" New topic
Author

UTFDataFormatException

Joseph Tulowiecki
Greenhorn

Joined: Jun 10, 2011
Posts: 25
(J2Me)
I'm trying to draw a background image in the gamecanvas to use as a background. It's a pacman game. The background I created in GIMP with in .png format. When I try to load the image I get this...

java.io.UTFDataFormatException: malformed input around byte 25

Code is as follows.

try{
backgroundImg = Image.createImage("/PacmanBackground.png");
}
catch (IOException e) {}

g.drawImage(backgroundImg, 0, 0, Graphics.TOP | Graphics.LEFT);

I'm very new I didn't know whether to put this in game section or beginners java section :O Any advice appreciated, thanks.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 4112
    
  19

Hi Joseph. Can you please post an SSCCE that demonstrates your problem?


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Joseph Tulowiecki
Greenhorn

Joined: Jun 10, 2011
Posts: 25
Hi I read your reply. Sorry about that. Next time I will remember to do that. However in this situation I have been playing around with it a little and I've come to the conclusion its not the code because I tried another .png image with the same code and it loaded fine. So the problem is obviously with the image. I tried opening it in paint and renaming it but still getting the same problem. It was originally created in paint. Anyone have any ideas?
Joseph Tulowiecki
Greenhorn

Joined: Jun 10, 2011
Posts: 25
Correction to previous reply. "It was originally created in paint." <-- Is suppose to be "It was was originally created in GIMP" ;]
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 4112
    
  19

I could have a look if you posted the particular image and an SSCCE.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UTFDataFormatException
 
jQuery in Action, 3rd edition