动画 GIF 导致 SplashScreen 为空 [英] Animated GIF leads to SplashScreen being null

查看:32
本文介绍了动画 GIF 导致 SplashScreen 为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能与此线程的副本很接近:Splashscreen 中的动画 GIF

I know this is probably close to a duplicate of this thread: Animated GIF in Splashscreen

但由于它似乎没有得到答复,我无法对此发表评论或任何事情,我很抱歉重新发布此信息,但如果有人能给我答案,那就太棒了.

But since it seems unanswered and I can't comment on it or anything I'm sorry to repost this but it would be awesome if someone could give me an answer.

我正在制作一款游戏,这款游戏需要很长时间才能开始.因此,我想在加载屏幕期间向用户提供反馈,以便他知道应用程序没有崩溃.这就是我使用 java 7 中的 SplashScreen API 的原因.

I am making a game and this game takes quite a lot of time to start. Therefore I want to give the user feedback during the loading screen so he knows the application hasn't crashed. That's why I use the SplashScreen API from java 7.

在 Eclipse 中,当我使用 VM 参数中的以下配置运行我的应用程序时,SplashScreen.getSplashScreen() 返回 null.

In eclipse, when I run my application using the following configuration in VM Arguments, SplashScreen.getSplashScreen() returns null.

-splash:src/aapplication/Splash.gif

但是当我使用此配置时,它工作正常(我必须将文件放在同一个包中,一个是 Splash.png,另一个是 Splash.gif):

But when I use this configuration, it works fine (I have to files in the same package, one is Splash.png and the other Splash.gif):

-splash:src/aapplication/Splash.png

在 jar 文件中(在 MANIFEST.MF 中),这不起作用:

In a jar file (in MANIFEST.MF), this doesn't work:

SplashScreen-Image: aapplication/Splash.gif

虽然这样做:

SplashScreen-Image: aapplication/Splash.png

我的 GIF 大小约为 1Mb,而 PNG 大小为 50kb.

My GIF is about 1Mb in size while the PNG is 50kb.

谁能向我解释为什么 GIF 甚至无法加载而 PNG 加载(我知道这不是路径,因为它们具有相同的路径)?

Can anyone explain to me why does the GIF can't even be loaded while the PNG does (I know it's not the path since they have the same)?

无论我看哪里,它都说它应该和 PNG 一样好用.

Everywhere I looked, it said it should work just as fine as for PNGs.

感谢您的帮助!

推荐答案

我想你会发现问题归结为两件事...

I think you'll find that the problem comes down to two things...

  1. 使用命令行参数 (-splash),Java 期望图像是文件系统上的文件,而清单文件期望它是嵌入式资源.
  2. Java 似乎无法播放优化的 gif,即其帧代表上一帧和当前帧之间的差异的 gif,而不是完整的图像(就初始屏幕而言).

我尝试使用

第一个图像失败,但第二个工作,差异,据我所知,是第一个优化,第二个没有......

The first image failed, but the second worked, the difference, as near as I can tell, is the first is optimised and the second is not...

这篇关于动画 GIF 导致 SplashScreen 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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