GeeCON Prague 2014*
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


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: 3647
    
  16

Hi Joseph. Can you please post an SSCCE that demonstrates your problem?
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: 3647
    
  16

I could have a look if you posted the particular image and an SSCCE.
 
GeeCON Prague 2014
 
subject: UTFDataFormatException