开发者

Hardware accelerate bitmap drawing in java

I want to be able to draw consecutive bitmaps (of type BufferedImage.TYPE_INT_RGB) of a video as quickly as possible in java. I want to know the best method in doing so. Does anyone have any advice where I should start? From what I've read, 2 options are: 1) Use GDI/GDI+ routines in a JNI dll working with JAWT (Im on Windows) 2) Use Java3D and apply Textures to a Box's face and rotate it to the camera

Im interesting in any advice on these topics as well as any others. I have done a decent amount of GDI/GDI+ programming in VB when i created an ActiveX control, so using GDI should be painless, but im guessing Java3D will utilize the GPU more (I could be wrong) and give better performance. What do you think? GDI and JAWT with my previous experience开发者_如何学运维, or start and new API journey with Java3D. Thanks in advance. :)


To obtain a fluid animation (if it what you want to get), you need to use double buffering. For doing this, you will need to create a new java.awt.Image (or a subclass like BufferedImage, or if you want OpenGL accelerated processing, VolatileImage) for each frame you want to display. If you haven't already done so, call Image.getGraphics() to get a java.awt.Graphics object (can also be useful to add your content to the Image). At the end, when you hidden Image is complete, call Graphics.draw() to replace the current display smoothly.

VolatileImage is OpenGL accelerated and much faster. When VolatileImage.getGraphics() is called, it actually returns a Graphics2D, which is also part of the accelerated graphic pipeline.

It works on Windows, Linux and Solaris, but you need to have OpenGL drivers installed for your graphic card.

Some additional refs:

Accelerated graphic pipeline:

http://download.oracle.com/javase/1.5.0/docs/guide/2d/new_features.html

http://www.javalobby.org/forums/thread.jspa?threadID=16840&tstart=0

Double buffering:

http://www.java2s.com/Code/Java/2D-Graphics-GUI/Smoothmoveusingdoublebuffer.htm

http://www.heatonresearch.com/articles/23/page2.html

http://www.javacooperation.gmxhome.de/BildschirmflackernEng.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜