Archived

This topic is now archived and is closed to further replies.

[java] Details of the ImageProducer

This topic is 6571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I do have a question that has been nagging me for a while: I rely extensively on the Image/ImageProducer/PixelGrabber classes in my Java code, and have so far treated them as very convenient in/output of 32-bit pixel data (ARGB) knowing that obviously "someone" converts these data to 16, 24 or whatever bitdepth/byteordering the actual display have when I display the images. I have been unable to find any in-depth information about this process - I am trying to squeeze as much out of my core graphics code as possible, and I feel this is a place I''ve been neglecting. Does anyone know if it is any use to create specific code for, say, 16-bit if thats the current display depth? Also, any references to hard-core java graphics programming sites/books would be appreciated, thanxx. /Niels

Share this post


Link to post
Share on other sites
Um,..., I have a question about the ImageProducer/ImageConsumer interfaces. It seems from your post that you just have to have an ImageProducer, right? Is an ImageProducer given to you by the environment (static method of some class or the toolkit class)? I''ve worked on animating GIF''s as sprites before (in Java of course)--that was fun--but I never bothered to learn much more about ImageProducers. A little info, please?

JoeG

Share this post


Link to post
Share on other sites
The image producer essentially builds an image from an array of integers. It is fast enough for animation, but I can''t help but think there''s an overhead involved.
An overhead, that is, that can be reduced by using the ImageProducer differently for different screen modes.

(It has a special "animation mode" in which it reuses the integer array, you simply call an "update()" method when you have changed something and need a new image)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This is the only thing I could find on the 2D api. It''s only the programmer''s guide from sun. I don''t know much about advanced imaging in java and I''m trying to learn about it myself. I was wondering if using something like RLE would speed up or slow down java. I''m not exactly sure if it''s possible or how it would be implemented either since i don''t think you can print directly to the screen in java.

http://java.sun.com/products/jdk/1.3/docs/guide/2d/spec/j2d-bookTOC.doc.html

Share this post


Link to post
Share on other sites
What versions have this 2D and 3D API in them? Ive been playing with games in Java and i keep hearing about these API''s.

Also, is Java really good enough to have full blown graphics like diablo or spartcraft? I mean can it still run it smoothly with all the graphics?
Plus is there any way to shorten the download time of all the pics used on a game?? I load all the images before the game continues, and it allready takes a fair time with the few i have. Ideas???

PEACE
GAZZ

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I found this site containing libraries for image loading in Java. Supposedly the libraries improve performance and memory handling. While not specifically relating to your question I thought this might be of interest.

http://www.vlc.com.au/~justin/java/images/

Share this post


Link to post
Share on other sites
2D/3D APIs are not standard in any of the Java packages distributed with browsers today - I.e. people have to download them specifically, and noboby (apart from programmers) does. This is the reason I stick to the ImageProducer/Image classes - they''ve been there since the pre-V1 JavaRT.

Regarding performance: Don''t expect to do a Quake 3 killer in Java (Unless you rely on dedicated graphics packages such as OpenGL) - DOOMII is not far out of reach though . Seriously, check out http://files.theparty.dk/cgi-m/tpa.cgi and look for Java Demos - should give you an impression of what is possible in pure Java (without dedicated 2D/3D APIs).

Download time IS a serious problem (and the main reason we do not have animated graphics at www.hexadome.net). The two main tricks used on that site are:

1) Store all graphics in larger images and jpeg it (one large image compress better than 50 small images with the same content) + store all game data in a single .zip file.

2) Map is generated on the fly from 4 basic texture maps, rather than having 2000 tiles.

The complete game (code, maps, graphics, HTML etc.) is less than 200K...

/Niels

Share this post


Link to post
Share on other sites
Java 2D is a critical part of the JFC, I can''t Imagine a browser plugin that does not support the jfc nowadays.

Share this post


Link to post
Share on other sites
Me neither, but the plug-in is a pain to work with. For instance, I was presenting an applet to my boss at work that used the plug-in when it just decided to not work and give an error. Now if that wasn''t enough for you, take a look at Sun''s forums and see how many people are complaining about the plugin. Finally not every platform has the plug-in available. His version of UNIX did not have a plug-in available for it, so I had to convert all my Java2 code to Java1.1 code (believe me that was a pain) and I lost some features (like fonts) that were only available in Java2. The point is, don''t depend on plug-ins because they are still new technology (like Java3D). Maybe in a couple years most everything will be ironed out, but I see no point in frustrating yourself

Share this post


Link to post
Share on other sites
Ain''t you missing my point?

The plugin requires client-side installation, right? Meaning the user needs to actively do something to make it work which means you are excluding like 98% of the market (number wild guess - don''t flame me)..

Unless it''s in the browser, it is - IMHO - useless. Which, unfortunately means we have to wait untill everyone is running IE5 (since neither Netscape nor the Mozilla open source group will probably ever get their sh*t together and build a decent alternative... An NO, NS4.6 doesn''t qualify - if you are looking for a bugged text viewer, use notepad.. Whoops, off on a wild tangent (wasn''t that the name of the company of some obscure DX preacher?) Ah, never mind - it''s late...)..

Also, last time I checked, performance of the plugin sucked...

/Niels

Share this post


Link to post
Share on other sites
Oh, sorry!

Jim said he couldn''t imagine any *plugin* that didn''t support JFC. If, by plugin, he means the one from Sun - then that requires just as much download and installation as the SDK itself, and is thus just as useless.

/Niels

Share this post


Link to post
Share on other sites
Cool. Talking about the plugin, I was surprised to see that intellicast.com (their American time zone applet) somehow got Swing to work without the plugin. I asked them how they did it, but haven''t gotten a response

Share this post


Link to post
Share on other sites
I heard someone say that it is now legal to distribute part of swing (The original license agreement required you to redistribute the full (12meg??) package) - if they are only using a small subset of the swing package, they could simply include those classes in their .jar...

/Niels

Share this post


Link to post
Share on other sites