|
Replies:
6
-
Last Post:
Nov 21, 2007 3:58 AM
by: marcosfj
|
|
|
|
|
|
|
Migrate from heavyweight to lightweight
Posted:
Oct 24, 2007 4:55 AM
|
|
|
Hello to everyone. Im make a bridge from the PVideoOutputDevice (a output class of PWLib project) to a AWT Canvas.
The bridge consists in a simple descendant on native side that instances a awt.Frame descendant, fill a java integer array and call the frame paint method. The frame contains a BufferedImage that is constructed manualy and have the integer array as they core, so each update on array is imediatly reflected by Buffered image. The frame contains a list of custons awt.Canvas. These custon canvas have a BufferedImage too, but these buffers is only a portion of the frame image (the way that I made for decomposing a frame of a conference video) The paint method of a frame simple update the BufferedImage (if necessary, a preparation to VolatileImage) and calls they canvas to update theirs contents too.
All this is made with AWT and works perfectly (we are very happy with the results, wrapping the OpenH323 to java with this java video window). But now I'm need to port this implementation to Swing fashion. But in Swing I can not use Cnvas class so, I'm asking for help of the community to indicate articles and forums topics to clarify how I can make or use a custon Swing component to draw on.
Thanks to everyone. Sorry any linguistic mistake.
Message was edited by: marcosfj
Message was edited by: marcosfj
|
|
|
|
|
|
|
[JAVA2D] Faster way to access bytes in image than .getElem()
Posted:
Oct 24, 2007 5:55 AM
in response to: marcosfj
|
|
|
I have an application where I have the image data in a ByteBuffer and I want to scan through the elements.
My Profiler shows getElem() or getElemDouble() as the major performance bottlenecks. Is there a way to convert a ByteBuffer to byte[] so I can scan the bytes much faster?
MArkee
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Faster way to access bytes in image than .getElem()
Posted:
Oct 24, 2007 6:49 AM
in response to: mark.stephens@u...
|
|
|
Hi Mark,
> I have an application where I have the image data in a ByteBuffer and > I want to scan through the elements. > > My Profiler shows getElem() or getElemDouble() as the major > performance bottlenecks. Is there a way to convert a ByteBuffer to > byte[] so I can scan the bytes much faster?
I suppose, you have the image data in a DataBufferByte. If that's the case, you can call getData() on it, to get hold of the underlying byte array data. If you _really_ mean ByteBuffer (java.nio), then you can try array().
Cheers, Roman
-- http://kennke.org/blog/
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Faster way to access bytes in image than .getElem()
Posted:
Nov 21, 2007 3:52 AM
in response to: mark.stephens@u...
|
|
|
Hi Mark
You can try mixing the suggestion posted by Roman. Use GetRaster to set the underlying byte array of the image then create a new ByteBuffer wraper on the same array, that way u can navigate in the bytes of the image using the interfaces of the new I/O.
Here are an example (modified) of how we populate the BufferedImage with the data come from PWLib, the 'raw' array are filled natively with JNI calls:
//we are using int arrays in the original code //switched to byte array for use with nio.ByteBuffer, need align to 4byte (RBGX) byte[] raw = new byte[frameWidth*frameHight*32]; ByteBuffer bb = ByteBuffer.wrap(raw); BufferedImage bi = new BufferedImage(frameWidth, frameHight, TYPE_INT_BGR); //<-- important!
//
|
|
|
|
|
|
|
|
Re: [JAVA2D] Faster way to access bytes in image than .getElem()
Posted:
Nov 21, 2007 3:54 AM
in response to: mark.stephens@u...
|
|
|
.
Message was edited by: marcosfj
|
|
|
|
|
|
|
|
Re: Migrate from heavyweight to lightweight
Posted:
Oct 24, 2007 6:28 AM
in response to: marcosfj
|
|
|
> All this is made with AWT and works perfectly (we are > very happy with the results, wrapping the OpenH323 to > java with this java video window). But now I'm need > to port this implementation to Swing fashion. But in > Swing I can not use Cnvas class so, I'm asking for > help of the community to indicate articles and forums > topics to clarify how I can make or use a custon > Swing component to draw on.
Usually, porting custom AWT components to Swing just involves subclassing JComponent (instead of Canvas) and moving the painting code from paint() to paintComponent(). Have you tried that approach?
--Chris
|
|
|
|
|
|
|
|
Re: Migrate from heavyweight to lightweight
Posted:
Nov 21, 2007 3:21 AM
in response to: invalidname
|
|
|
I'm not yet tried JComponent (let me search about it), meanwhile I'm searching examples and topics of how to make such thing. I think it's not much difficult because the primary problem has resolved with the underlying array of the BufferedImage.
If you know any good explained articles, slides or forums posts, can please share it with us?
Thanks for the attention.
|
|
|
|
|