简体   繁体   English

在Java中显示时,gif透明性上的黑条?

[英]Black bars on transparency in gif when displaying in Java?

For a project for our Advanced Java class, a group of friends and I are building a fighting game. 对于我们的Java高级课程,我和一群朋友正在制作一个格斗游戏。 To display the characters, we're saving animated gifs to ImageIcons and then in the paintComponent method of the panel we're using 为了显示字符,我们将动画gif保存到ImageIcons中,然后在面板的paintComponent方法中使用

icon.paintIcon(this.getAssociatedGamePanel(), g, getLeftSide(), getTopY());

to display the icon, as this was the easiest way I could find to display the icon. 显示图标,因为这是我发现显示图标的最简单方法。 The only problem is some of that the gifs will display strange black bars in parts of the transparencies. 唯一的问题是其中的gif会在部分透明胶片中显示奇怪的黑条。 For Example, http://i.stack.imgur.com/yAjZY.gif 例如, http://i.stack.imgur.com/yAjZY.gif

is our gif for the low kick. 是低踢的我们的gif。 When we display it in Java, it looks like this: http://i.stack.imgur.com/W6HBb.png 当我们用Java显示它时,它看起来像这样: http : //i.stack.imgur.com/W6HBb.png

I've tried using various gif optimization tools, making sure I erased the transparency completely, and various other things, but haven't been able to make the bars disappear. 我尝试使用各种gif优化工具,以确保完全擦除了透明度以及其他各种功能,但无法使这些条消失。 One image optimization tool turned the bars white, but that's the only thing I've been able to do. 一个图像优化工具使条形变为白色,但这是我唯一能做的。 What are some things I could try in order to get rid of the black bars? 为了摆脱黑条我可以尝试哪些措施?

@wewtaco, I noticed that your PNG file has wider dimension than the Gif file and I am guess that could be a reason the black bars are showing up. @wewtaco,我注意到您的PNG文件比Gif文件具有更宽的尺寸,我想这可能是出现黑条的原因。 Can you try keeping the size same or the view area of the icons same...and see if that fixes...Also, the PNG file is not background transparent...it might be carrying some colors from its original source..that could be another reason. 您可以尝试保持大小不变​​还是图标的视图区域相同...看看是否可以解决...此外,PNG文件不是背景透明的...它可能带有某些原始颜色。那可能是另一个原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM