[java] Details of the ImageProducer

Started by
12 comments, last by Niels 24 years, 3 months ago
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
<b>/NJ</b>
Advertisement
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
joeG
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)
<b>/NJ</b>
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
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
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/
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
<b>/NJ</b>
Java 2D is a critical part of the JFC, I can''t Imagine a browser plugin that does not support the jfc nowadays.
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
joeG
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
<b>/NJ</b>

This topic is closed to new replies.

Advertisement