硬件加速java中的位图绘制 [英] Hardware accelerate bitmap drawing in java

查看:299
本文介绍了硬件加速java中的位图绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在java中尽快绘制视频的连续位图(类型为BufferedImage.TYPE_INT_RGB)。我想知道这样做的最佳方法。有没有人有任何建议我应该从哪里开始?根据我的阅读,2个选项是:
1)在使用JAWT的JNI dll中使用GDI / GDI +例程(我在Windows上)
2)使用Java3D并将Textures应用到Box的脸部和将它旋转到相机

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

我对这些主题以及其他任何主题的任何建议都很有趣。
当我创建一个ActiveX控件时,我在VB中做了大量的GDI / GDI +编程,所以使用GDI应该是无痛的,但我猜Java3D会更多地使用GPU(我可能是错的)并提供更好的性能。你怎么看? GDI和JAWT与我以前的经验,或者与Java3D一起开始和新的API之旅。
提前致谢。 :)

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. :)

推荐答案

要获得流畅的动画(如果你想获得),你需要使用双缓冲。为此,您需要为要显示的每个帧创建一个新的java.awt.Image(或者像BufferedImage这样的子类,或者如果您想要OpenGL加速处理,VolatileImage)。如果您还没有这样做,请调用Image.getGraphics()以获取java.awt.Graphics对象(对于将您的内容添加到Image中也很有用)。最后,当您隐藏Image完成时,调用Graphics.draw()以平滑地替换当前显示。

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加速OpenGL并且速度更快。当调用VolatileImage.getGraphics()时,它实际上返回一个Graphics2D,它也是加速图形管道的一部分。

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.

它适用于Windows,Linux和Solaris,但是您需要为您的图形卡安装OpenGL驱动程序。

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

一些额外的参考:

加速图形管道:

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

这篇关于硬件加速java中的位图绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆