java中的硬件加速位图绘制
我希望能够在java中尽快绘制视频的连续位图(类型为BufferedImage.TYPE_INT_RGB)。我想知道这样做的最佳方法。有人对我应该从哪里开始有什么建议吗?根据我的阅读,有两个选择: 1)在与 JAWT 一起使用的 JNI dll 中使用 GDI/GDI+ 例程(我在 Windows 上) 2)使用Java3D并将纹理应用到盒子的脸上并将其旋转到相机
我对这些主题以及其他主题的任何建议都很感兴趣。 当我创建 ActiveX 控件时,我已经在 VB 中完成了大量的 GDI/GDI+ 编程,因此使用 GDI 应该很轻松,但我猜测 Java3D 会更多地利用 GPU(我可能是错的)并提供更好的性能。你怎么认为? GDI 和 JAWT 是我以前的经验,还是用 Java3D 开始新的 API 之旅。 提前致谢。 :)
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. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获得流畅的动画(如果您想要获得的话),您需要使用双缓冲。为此,您需要为要显示的每个帧创建一个新的 java.awt.Image(或像 BufferedImage 这样的子类,或者如果您想要 OpenGL 加速处理,则创建 VolatileImage)。如果您还没有这样做,请调用 Image.getGraphics() 来获取 java.awt.Graphics 对象(也可用于将内容添加到 Image)。最后,当隐藏Image完成后,调用Graphics.draw()平滑地替换当前显示。
VolatileImage 是 OpenGL 加速的并且速度更快。当调用 VolatileImage.getGraphics() 时,它实际上返回一个 Graphics2D,它也是加速图形管道的一部分。
它适用于 Windows、Linux 和 Solaris,但您需要为图形卡安装 OpenGL 驱动程序。
一些其他参考:
加速图形管道:
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
双缓冲:
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
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