我想为Frame(或JFrame)创建一个完全透明的背景,并让它显示透明动画.我设法让它在Windows 7 x64中运行,但相同的代码不能在我的Linux上运行(Lubuntu x64 15.04).
下面的代码显示了我想要实现的目标 - 只需复制并粘贴即可.我只是希望小矩形在屏幕上移动而不留下痕迹.
static int a = 0;
public static void main(String[] args) {
JFrame f = new JFrame();
f.setUndecorated(true);
f.setBackground(new Color(0, 0, 0, 0));
f.setVisible(true);
f.setSize(512, 512);
f.add(new JPanel() {
@Override
public void paintComponent(Graphics gr) {
Graphics2D g = (Graphics2D)gr;
g.setBackground(new Color(0, 0, 0, 0));
g.clearRect(0, 0, 512, 512);
g.drawRect(a, a++, 2, 2);
}
});
while(true) {
try {
Thread.sleep(30);
} catch(InterruptedException e) {
e.printStackTrace();
}
f.repaint();
}
}
Run Code Online (Sandbox Code Playgroud)
我想要实现的目标(如Windows中所示)以及我使用Lubuntu 15.04获得的内容:

我只想看到小方块移动就像在Windows 7上显示的那样 …
我正在开发一个平滑的60 FPS 1080p(全高清)视频传输应用程序,它以x264编码,通过LAN将编码数据发送到接收设备,接收设备然后使用OpenH264的解码器对其进行解码.我设法让它工作,它工作正常并且稳定,但我发现它非常慢(大约20 FPS而不是所需的60 FPS).
我做了大量测试,发现问题在于OpenH264解码器.
解码器使用我的i5-2500 @ 3.9Ghz的完整核心(总CPU使用率为25%),这太高了.尽管解码器是单线程的,但我在Media Player Classic上测试了原始数据,并且它的播放(60 FPS)仅占CPU使用率的0.3%.(将渲染引擎切换为"旧视频渲染"时,CPU使用率增加到12.8-14.4% - 请参阅注释)
所以我的问题是:我可以做些什么来加速解码过程以及我做错了什么?我无法想象OpenH264会如此缓慢.
以下是与解码器相关的所有C++代码:
ISVCDecoder *decoder;
SBufferInfo bufferInfo;
SDecodingParam decodingParam;
uint8_t** yuvData;
void init(int width, int height) {
WelsCreateDecoder(&decoder);
decodingParam = { 0 };
decodingParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
decoder->Initialize(&decodingParam);
bufferInfo = { 0 };
yuvData = new uint8_t*[3];
yuvData[0] = new uint8_t[width*height];
yuvData[1] = new uint8_t[width*height / 4];
yuvData[2] = new uint8_t[width*height / 4];
}
bool …Run Code Online (Sandbox Code Playgroud) background ×1
c++ ×1
codec ×1
h.264 ×1
java ×1
jframe ×1
linux ×1
openh264 ×1
performance ×1
transparent ×1