Problem with gif with transparent background

We Are Going To Discuss About Problem with gif with transparent background. So lets Start this Java Article.

Problem with gif with transparent background

Advertisements
  1. Problem with gif with transparent background

    Your gif is disposal = 3 that means it needs previous image as it renders incrementally. The problem is the image is with black background and not white …
    Here are the disposals possible:
    if (disposal==0) s="no animation"; else if (disposal==1) s="leave image as is"; else if (disposal==2) s="clear with background"; else if (disposal==3) s="restore previous image"; else s="reserved";

  2. Problem with gif with transparent background

    Your gif is disposal = 3 that means it needs previous image as it renders incrementally. The problem is the image is with black background and not white …
    Here are the disposals possible:
    if (disposal==0) s="no animation"; else if (disposal==1) s="leave image as is"; else if (disposal==2) s="clear with background"; else if (disposal==3) s="restore previous image"; else s="reserved";

Solution 1

Advertisements

here another one How to fix .gif with corrupted alpha channel (stuck pixels) collected with Graphicsmagick?

Your gif is disposal = 3 that means it needs previous image as it renders incrementally. The problem is the image is with black background and not white …

Here are the disposals possible:

     if (disposal==0) s="no animation";
else if (disposal==1) s="leave image as is";
else if (disposal==2) s="clear with background";
else if (disposal==3) s="restore previous image";
else                  s="reserved";

When I render it with my decoder it looks like this:

[![capture][1]][1]

So there are 2 possible things at play here:

  1. transparency

maybe this should be handled as transparent image with background but even decent image viewer (like FastStone Image Viewer) shows the same thing so I doubt this is the case…

  1. extentions

This is the most likely cause. Nowadays WEB browsers (for few years now) depend on undocumented custom made extentions added to GIFs extention packets (and not part of any GIF specs) and ignores the GIF file format completely for some aspects of rendering (like looping). Simply because all of them use the same image lib for decoding GIFs which is simply coded badly (or by design)…

for more info see:

So my guess is the GIF of yours have some extention packet telling brownser to use different disposal method then the one stored in GIF header. So simply your GIF is buggy and only buggy GIF decoder can render it properly …

So your decoder ignores the background color of GIF hence rendering incorrectly as the incremental render does not work with non black color background …

And yes those white lines are with gaps … its not aliasing …
[1]: https://i.stack.imgur.com/6Kbbp.gif

Original Author Spektre Of This Content

Solution 2

Advertisements

You’ve overridden the paint method in your JFrame. This means that the JFrame itself no longer gets painted (or to put it more simple, the background of your image never gets painted). Insert a call to super.paint(g) in the paint method above where you paint the image, so that the background gets painted over the previous gif image every time a new gif image shows:

@Override
public void paint(Graphics g) {
    super.paint(g);
    g.drawImage(TestImage, 0, 0, 300, 300, this);
}

Original Author Pieter12345 Of This Content

Conclusion

Advertisements

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Advertisements
Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment