riemer
asked on
Decompress and display jpeg image from memory (not file!)
I know I can read and display jpeg images directly from a jpeg file, but I've got a jpeg image (compressed) already in memory (via native code out of a QuickTime movie).
Can I utilize Java methods to decompress (and then display) this jpeg image directly from memory?
Can I utilize Java methods to decompress (and then display) this jpeg image directly from memory?
ASKER
Thanks for the instant answer BUT:
Sorry, that's not what I want. I'm keeping compressed jpeg images in memory to have a sort of cache to
a) speed up image re-display e.g. from a slower net or cdrom I/O and
b) keep it compressed to save wasting memory like a raw image would do.
Writing it to a local disk and reading it back is still costing too much time for me.
Sorry, that's not what I want. I'm keeping compressed jpeg images in memory to have a sort of cache to
a) speed up image re-display e.g. from a slower net or cdrom I/O and
b) keep it compressed to save wasting memory like a raw image would do.
Writing it to a local disk and reading it back is still costing too much time for me.
Well, it will HAVE to be uncompressed in order to be displayed!
ASKER
I DO agree. Currently I'm using a native jpeg library which is probably less efficient **) (I hope) than a genuine Java solution doing it all with its Java jpeg library I can see e.g. in win95 "jpeg.dll".
**) less efficient is: I/O + decompress (60 % of the time) + display (40 %) (100 % = 300 ms for a 256x256 image on a Pentium 120 MHz) - I'm hoping to reduce the 60 % portion.
**) less efficient is: I/O + decompress (60 % of the time) + display (40 %) (100 % = 300 ms for a 256x256 image on a Pentium 120 MHz) - I'm hoping to reduce the 60 % portion.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm tempted to grade your answer as "Good" - if there really is no 100% pure Java solution ... isn't there any, how sure are you?
(I'm hesitating to put something in which is not 100% pure Java)
(I'm hesitating to put something in which is not 100% pure Java)
No, I'm sure there is a 100% pure java solution.
1) I don't have JPEG code (like I said, I already wrote a class for GIF, 100% java).
2) It would probably be slow.
You may want to try it, though. See if you can find JPEG code in C, then port it to Java. I can give you my GIF code as a guide on how images work in Java.
1) I don't have JPEG code (like I said, I already wrote a class for GIF, 100% java).
2) It would probably be slow.
You may want to try it, though. See if you can find JPEG code in C, then port it to Java. I can give you my GIF code as a guide on how images work in Java.
ASKER
Thanks for your last comment. I DO need speed. I've been hoping for a 100% pure STANDARD Java solution - possibly internally in native code like (I suppose) some of the display functions are to speed it up (e.g. using the win95 jpeg.dll). I think I'll have to go back to my own native code and port it from platform to platform (written in C and - important for me - quite FAST)
Save the memory buffer to a temporary file.
Load the temporary file with Toolkit.getImage()
BTW, if you wanted GIF, I could give you a class that does it (and also supports GIF animations!)