Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problems loading images (png) in browser  (Read 1386 times)
0 Members and 1 Guest are viewing this topic.
Offline Tiko

Senior Newbie


Projects: 1



« Posted 2008-08-07 12:13:57 »

Hello.

I have a game running in Applet and it works fine with Applet Viewer. And it works fine when I run it in a browser from my own computer. But when I try to load the game over the Internet, some pictures won't load. JPGs work fine, haven't tried with GIFs, but PNGs won't load at all.

I load the image like this:
1  
image = ImageIO.read(new BufferedInputStream(ImageBase.class.getClassLoader().getResourceAsStream(name)));


I found out that there is a bug with read andBufferedInputStream should fix it. Well, it doesn't fix it in this case. Any ideas?

Edit: I tried to load the images with getImage and mediatracker but the same problem occurs. It's pretty odd... I've never had this problem before.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11


Game Engineer


« Reply #1 - Posted 2008-08-07 23:22:39 »

Are you sure the URL is correct?

See my work:
OTC Software
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #2 - Posted 2008-08-08 00:30:04 »

Got a URL to the png so we can take a look?

Alternatively, have a look at the png yourself with tweakpng

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Tiko

Senior Newbie


Projects: 1



« Reply #3 - Posted 2008-08-08 08:26:38 »

There are many PNGs but here is an example: http://koti.mbnet.fi/johann/Code/java/Coloribrium/red.png. The URL is correct because all the images are in the same folder and JPGs work. And it works perfectly when running from my own computer (with browser and applet viewer). Only over the internet there is problems.

Maybe JAR could fix the problem? I've never used JAR so I guess it's time to learn. But still, why doesn't it work like that...

Edit: Doesn't work in JAR either. Exactly the same problem. Still works from my own computer but not from the Internet.

Edit: I don't know why I didn't check this out earlier, but when I load the image it throws an exception which says "Width (-1) and height (-1) cannot be <= 0"... This is sooo strange.

Edit: And ofcourse, you could also try it. http://koti.mbnet.fi/johann/Code/java/Coloribrium/. If it works for you, you should see some diamonds or something on the screen.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11


Game Engineer


« Reply #4 - Posted 2008-08-09 00:07:13 »

That exception is often the result of a failed image load. Are you throwing exceptions during the load as well? If not, you should.

See my work:
OTC Software
Offline Tiko

Senior Newbie


Projects: 1



« Reply #5 - Posted 2008-08-09 11:14:24 »

Problem solved! This was really a tough one. Who would have guessed that getResourceAsStream is case sensitive over the Internet but not on your own computer? I hope this topic will someday help someone else so that I didn't suffer this for nothing.   Tongue
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11


Game Engineer


« Reply #6 - Posted 2008-08-09 23:05:06 »

Mmm, makes sense that this would be the problem. I figured it was related to actually finding the image. Glad you figured it out!

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (33 views)
2014-07-18 06:55:21

Zero Volt (29 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (26 views)
2014-07-16 23:30:00

Cero (41 views)
2014-07-16 00:42:17

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (65 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!