Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  Fast image loading  (Read 2821 times)
0 Members and 1 Guest are viewing this topic.
Offline Middy

Junior Devvie




Java games rock!


« Posted 2005-02-03 06:40:24 »

Struggling with java IO and it seems a bit slow in reading large images.

Is there a fast image loading lib? awt,javax,java2d,java.jai

Huh

When do I get my makeMyGameAsILike() extension?
Offline Spasi
« Reply #1 - Posted 2005-02-03 07:19:04 »

javax.imageio.ImageIO.read(), but the speed depends on the image type. If you ever implement a custom image loader (tga and tiff are really simple) then go for NIO/Buffers.
Offline princec

« JGO Spiffy Duke »


Medals: 434
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2005-02-03 08:12:34 »

DevIL, in LWJGL...

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Middy

Junior Devvie




Java games rock!


« Reply #3 - Posted 2005-02-03 16:15:41 »

Yeah, I considered that one too...

The problem is that java IO is too slow. Its a virtual file system and have to display these images pretty fast (while browsing)

When do I get my makeMyGameAsILike() extension?
Offline MasterOfDisaster

Junior Devvie




O_o


« Reply #4 - Posted 2005-09-09 18:49:00 »

just stumbled across this thread while i was searching for a fast way to load images. i'm currently working on a little photo viewer program and i would like to find a really fast way to load big images (digicam photos). currently loading such an image takes about half a second. i even implemented preloading threads but the performance of the tool is way behind a standard photo viewer tool like the "windows image and fax viewer" app in WinXP. additionally the app uses about 100 megs of ram. seems like i'm soing something terribly wrong  Undecided

maybe someone could point me in the right direction. LWJGL was mentioned above but is there really no way to do it with plain java 2d?

Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #5 - Posted 2005-09-10 00:33:53 »

im sure you can extract the data loaded by DevIL and create a BufferedImage through it somehow...

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline MasterOfDisaster

Junior Devvie




O_o


« Reply #6 - Posted 2005-09-10 09:54:43 »

can you give me a rough estimation of the speed increase i can expect when using DevIL?

Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #7 - Posted 2005-09-10 10:10:20 »

what you must understand is that DevIL doesnt' do anything special, all it does is load the image. ImageIO does alot of transformations and conversions so that the image is compatible with J2D.

However, those conversions and transformations are infact very time consuming, and with DevIL, I saw a 10x to 20x speed increase if not more. And that is definetly a rough estimation.

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline MasterOfDisaster

Junior Devvie




O_o


« Reply #8 - Posted 2005-09-10 11:28:49 »

cool, i'll give it a try. thanks for the info ...

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #9 - Posted 2005-09-11 00:46:23 »

ImageIO does alot of transformations and conversions so that the image is compatible with J2D.

What sort of transformations and conversions?

I have never heard of ImageIO doing any sort of transformations.  Though when I was testing Java 1.4 I did find that the JPEG image loaders (Toolkit and ImageIO) were dog slow.

I assume that the JPEG codec is simply not optimized using assembler and SIMD instructions like a proper image loader.  I've whined about it to Sun, but it doesn't seem to be a priority for them.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline MasterOfDisaster

Junior Devvie




O_o


« Reply #10 - Posted 2005-09-11 09:10:11 »

im sure you can extract the data loaded by DevIL and create a BufferedImage through it somehow...

DP

i'm currently struggling with this particular problem but cannot find a solution (ByteBuffer -> BufferedImage) ...  Sad

Offline Jeff

JGO Coder




Got any cats?


« Reply #11 - Posted 2005-09-12 07:17:36 »

I had speed problems at first with JNWN, profiled, and found out it was the imageio TGA loader I was using, which was really really slow.

I wrote my own image loading code instead and got massive performance improvements.

The morla here is not "don't use imageio".  The moral is that any performance work begins and ends with a profile.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline MasterOfDisaster

Junior Devvie




O_o


« Reply #12 - Posted 2005-09-12 10:16:09 »

but darkprophet was right, DevIL loaded a particular image in 140ms on my machine, ImageIO needed about 500ms for the same image.
the only thing i need now is either
+ a way to converter the ByteBuffer to a BufferedImage or Image in order to draw it with J2D or
+ a way to directly draw the image loaded with DevIL

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #13 - Posted 2005-09-12 12:47:18 »

The morla here is not "don't use imageio". 

Um.. Am I the only one that finds it a bit odd that a Sun engineer is specifically stating "don't use imageIO" for loading images because it isn't fast enough, when the soul purpose of that API is to load images?

Quote
The moral is that any performance work begins and ends with a profile.
Shouldn't Sun take this advice and *fix* imageIO?  I realize that it has to be a general purpose image loader.. but I don't believe that means it has to be nearly as slow as it is.  The imageIO API should be the the preferred way to load images in most cases.. why have it if everyone ends up rolling their own?

It seems like the same sort of strategy that effectively killed JMF.  Sun comes up with a good thing, drops the ball, and it ends up no good for anyone.

Offline kevglass

« JGO Spiffy Duke »


Medals: 212
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #14 - Posted 2005-09-12 13:13:07 »

Quote
Um.. Am I the only one that finds it a bit odd that a Sun engineer is specifically stating "don't use imageIO" for loading images because it isn't fast enough, when the soul purpose of that API is to load images?

No no, he said the opposite (after you decode the Jeffese)

Quote
The morla here is not "don't use imageio".

The moral here is *not*   -   "don't use imageio" - i.e. don't take as him saying "don't use imageio".

In my experience ImageIO is pretty good until you reach larger images.

To create a BufferedImage from a byte array (or ByteBuffer) use the setRGB() method on BufferedImage. Theres a discussion about it here: http://forum.java.sun.com/thread.jspa?threadID=500995&messageID=2368658

Kev

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #15 - Posted 2005-09-12 13:36:29 »

Ah..  I missed the double negative...

Though his conclusion still seems to be at least that TGA loading in imageIO is slow.
My own tests show that JPEG image loading is very slow. (that was with Java 1.4, haven't tested since)
Then there is the thread discussing how PNG loading is broken...

The moral of MY story... "ImageIO needs some attention"  Smiley

Offline Jeff

JGO Coder




Got any cats?


« Reply #16 - Posted 2005-09-12 21:56:12 »

Ah..  I missed the double negative...

Though his conclusion still seems to be at least that TGA loading in imageIO is slow.

Yup, though to be fair it wasnt a Sun loader, the imageio we ship doesn t have a TGA loader so iw as using a third party one.

But it was indeed a dog.

Quote
My own tests show that JPEG image loading is very slow. (that was with Java 1.4, haven't tested since)
Then there is the thread discussing how PNG loading is broken...

The moral of MY story... "ImageIO needs some attention"  Smiley


Probably, though since the loader interface is open and you cna plug them in on the fly, the community could always write its own package of acceleerated loaders.
(I warn you though, they laoder inetrface is huge and pretty complex 'cause they decided they wante to support every weird use case they could come up with.)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
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.

rwatson462 (33 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (51 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (60 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!