A quick note.

I am working on a 360 panorama viewer.  I'll describe briefly my architecture.

I load images using my own file loader class from a separate thread spawned 
from the init() method of my applet.  I download the image file as bytes in an 
ordinary file transfer.  Once I have the image bytes I send them through the 
appropriate decoder to get an image.

I then suck the pixels out of the image.  Once I have the pixels, I flush() the 
image so all I have on the heap (I think they are on the heap) is the pixels in 
an integer array (in my case).

Then in another class I call the projection class, I take whatever small piece 
of the pixel array I want to display -- apply whatever transform or 
interpolation I want directly on a small copy of my working set and then stuff 
those pixels into a MemoryImageSource that lives in my class that manages the 
drawing.  I work on the pixels directly in plain Java.

Yes I have to write my own implementations of my interpolators and translators 
and scalers or overlays or whatever, but that's where the fun and efficiency 
comes in.

My drawing class has a BufferStrategy.  After I newPixels() into the 
MemoryImageSource, I use the BufferStrategy graphics to draw the 
MemoryImageSource and then just show().

If I want to show portions of a different image, I repeat the process.  It's 
fairly fast and really simple.

BufferStrategy does all the VolitileImage managment I need.

And I have an eventHandler loop that wakes up every 5ms to handle mouse and 
keyboard events that controls the projection process -- pan,tilt,zoom,etc.  I 
set flags and values from the AWT event thread in a normal way so the AWT event 
thread doesn't hang waiting for me to finish anything and my eventhandler just 
loops through reading those flags and values as directives.

Simple, small and fast.

Your milage may vary...

Ken

[EMAIL PROTECTED] wrote:
Chris,


i=0 --> copy mapImage (in sysmem) to dummyImage (in VRAM)
i=1 --> a) copy mapImage (in sysmem) to cached texture version of
mapImage (in VRAM)
b) copy mapImage (texture in VRAM) to dummyImage (in VRAM)
later --> copy mapImage (texture in VRAM) to your Swing backbuffer
(in VRAM)


Thanks for your insight. So I guess there is nothing I can do to speed up what 
you mention happens later. It seems there is no easy way to copy mapImage to 
the Swing backbuffer in anything other than the EDT (In fact I suggest the 
attempting to do so while more EDT's are on the way may really screw with 
Swing).

I think I need to describe what I am trying to do, and why I can not think of a 
strategy better than spawning a Thread from paintComponent(). This thread does 
all of the work associated with loading an image from file (if it is not 
loaded) and then doing everything up to step 1b above. Think of scrolling and 
zooming in a 'GoogleEarth' like interface. Initially you have a base image, as 
you zoom in you move through layers other images, as you pan you see 
surrounding images. Scrolling and zooming occurs in response to mouse and key 
events, these in turn alter the model and a repaint of the state occurs. In 
each session hundreds, or even thousands, of 1000x1000 pixel images may be 
loaded. Keeping all of these in memory, just in case they are needed again, is 
not practical. Rather I ensure that only those that are needed are loaded then 
discarded when they are no longer needed. So this is smooth I currently 
determine which images should be displayed in paintComponent() then sp
awn a thread to do the loading work(if not already spawned), actually only 
displaying the image after it is loaded. I guess I could move this further 
back, however it will still occur in the EDT. (Well maybe not, I could have a 
separate thread polling the zoom/pan state at some regular interval to 
determine which images should be loaded, or maybe use some loosely coupled 
propertyChangeEvent mechanism to manage the zoom/pane state and leverage of 
that - More to think about...)

I did the single pixel thing - works fine on both pipelines on my machine.

Regards,

Alistair
[Message sent by forum member 'alnrelly' (alnrelly)]

http://forums.java.net/jive/thread.jspa?messageID=218476

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to