Java gif splashscreen weird bug

Today I checked to show gif with java splashscreen option. This works, but ... When repeating the splash screen, my gif shows a strange graphic error ...

enter image description here

This error appears only in a Java application.

This is the original gif:

enter image description here

Code

public class Bootstrap {
private SplashScreen splash;

public static void main(String[] args) {
    Bootstrap bootstrap = new Bootstrap();
    bootstrap.start();
}

public void start() {

    // Here i load the splash
    splash = new SplashScreen("UC", new ImageIcon(getClass().getResource("splash3.gif")).getImage());
    AWTUtilities.setWindowOpaque(splash, false);
    splash.setVisible(true);
}
}

SplashScreen.java

public class SplashScreen extends JFrame {
public SplashScreen(String title, Image image) {
    this.setTitle(title);
    this.setUndecorated(true);
    this.setDefaultCloseOperation(3);
    this.setSize(image.getWidth(this), image.getHeight(this));
    this.setLocationRelativeTo((Component)null);
    this.setContentPane(new SplashPanel(image));
}
}

Splashpanel.java

class SplashPanel extends JPanel {
private Image image;

public SplashPanel(Image image) {
    this.image = image;
}

public void paintComponent(Graphics g) {
    g.drawImage(this.image, 0, 0, this.getWidth(), this.getHeight(), this);
}
}

Apparently, this is simply because the gif is interlaced. :) Just uncheck this when you export the gif from Photoshop ... :)

+4
source share
1 answer

Apparently, this is simply because the gif is interlaced. Just uncheck this box when you export a gif from Photoshop ... :)

0
source

Source: https://habr.com/ru/post/1609390/


All Articles