Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UTFDataFormatException

 
Joseph Tulowiecki
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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
Pie
Posts: 6081
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joseph. Can you please post an SSCCE that demonstrates your problem?
 
Joseph Tulowiecki
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 6081
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could have a look if you posted the particular image and an SSCCE.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic