Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

You must login to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Passionable Logo Passionable Logo
Sign InSign Up

Passionable

Passionable Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • New Questions
  • Trending Questions
  • Must read Questions
  • Hot Questions
Home/ Questions/Q 5602
Next
In Process
Alek Richter
  • 0
Alek RichterEnlightened
Asked: December 14, 20212021-12-14T05:45:45+00:00 2021-12-14T05:45:45+00:00In: Language

Problem with gif with transparent background

  • 0

I have a problem with displaying my gif with a transparent background because when I start this program, my gif shows but all pictures of gif stayed on the canvas. Knows somebody some solution, please?

enter image description here enter image description here

This is my code:

package zkouska3;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class mainl extends JFrame{
    private Image TestImage;

    private BufferedImage bf;

    public static void main(String[] args) {
        new mainl();
    }

    public mainl() {
        setSize(500, 500);
        imageLoader();
        setVisible(true);
    }
    public void imageLoader() {
        try {
            TestImage = new ImageIcon(this.getClass().getResource("pandulak.gif")).getImage();
        }catch(Exception e) {

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

}
  • 1 1 Answer
  • 9 Views
  • 0 Followers
  • 0
    • Report
  • Share
    Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Alek Richter Enlightened
    2021-12-14T05:46:19+00:00Added an answer on December 14, 2021 at 5:46 am

    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:

    • Animated gif only loops once in Chrome and Firefox

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 4k
  • Best Answers 0
  • Users 2
  • Popular
  • Answers
  • Alek Richter

    Make MS Word document look like it has been typeset ...

    • 2 Answers
  • Alek Richter

    When does a process get SIGABRT (signal 6)?

    • 2 Answers
  • Alek Richter

    How do I add sockets to an item?

    • 2 Answers
  • Alek Richter
    Alek Richter added an answer Pandas DataFrame columns are Pandas Series when you pull them… January 13, 2022 at 2:21 pm
  • Alek Richter
    Alek Richter added an answer The handshake failure could have occurred due to various reasons:… January 13, 2022 at 2:19 pm
  • Alek Richter
    Alek Richter added an answer Mac OS X doesn't have apt-get. There is a package… January 13, 2022 at 2:18 pm

Related Questions

  • Alek Richter

    Easiest way to convert int to string in C++

    • 1 Answer
  • Alek Richter

    Get the full URL in PHP

    • 1 Answer
  • Alek Richter

    TypeError: a bytes-like object is required, not 'str' when writing ...

    • 1 Answer

Top Members

Alek Richter

Alek Richter

  • 4k Questions
  • 1k Points
Enlightened

Trending Tags

questin question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • New Questions
  • Trending Questions
  • Must read Questions
  • Hot Questions

© 2021 Passionable. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.