Results 1 to 15 of 15

Thread: [VB6] Creation of GIF-animation with the transparent background.

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,671

    [VB6] Creation of GIF-animation with the transparent background.

    Hi everyone!
    This project allows to create an GIF animations with the transparent background. As far as i know the GDI+ doesn't allow to set the property of "Disposal Method" in the "Graphic Control Extension" block, therefore each next frame is overlayed to the previous frame. For the opaque frames it's doesn't matter. In order to solve this issue i decide to change the needed bytes manually in the raw GIF file.
    It allows to prevent the restrictions of the transparent frames. Also this example contains the oct-tree class, which calculates the optimal palette for the each frame. There are the ability of the additional settings: threshold of the transparency, duration, and number of the loops for entire animation. For the disabling of the transparency enough set the threshold to zero. The greater the value of the threshold field the greater semitransparent pixels become transparent completely.

    Name:  Безымянный.png
Views: 4044
Size:  105.4 KB
    Regards,
    Кривоус Анатолий.
    Attached Files Attached Files

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] Creation of GIF-animation with the transparent background.

    Setting the GIF frame structure to specifically define the disposal code is the right choice, I agree. A couple of other points of interest

    1. GdipGetImageThumbnail is ok, however, it can produce poor scaling. Just FYI

    2. GdipSaveAddImage does not work on earlier versions of GDI+ for GIFs. Maybe there should be a validation check?

    3. You may want to check to see a color table is being created for every frame. If it is, then the GIF can be much larger than needed. Without checking, I don't know if GdipSaveAddImage creates a local color table per frame or if it changes the pixel data to force using the global color table. In my projects, I build a color table that can be used by the most frames and set that color table as global and tell each of those frames to use the global. For the remaining frames that cannot use it, they keep their local color table.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,671

    Re: [VB6] Creation of GIF-animation with the transparent background.

    LaVolpe, thanks for response.
    Quote Originally Posted by LaVolpe View Post
    1. GdipGetImageThumbnail is ok, however, it can produce poor scaling. Just FYI
    Ok, i didn't know. Thanks.
    Quote Originally Posted by LaVolpe View Post
    GdipSaveAddImage does not work on earlier versions of GDI+ for GIFs. Maybe there should be a validation check?
    Yes, as far as i know it doesn't work in XP. I was having my own code for the creation GIF frame, but it's written on C++. Maybe ever i'll update this code. Honestly, it is old project, i just posted it here.
    Quote Originally Posted by LaVolpe View Post
    You may want to check to see a color table is being created for every frame. If it is, then the GIF can be much larger than needed. Without checking, I don't know if GdipSaveAddImage creates a local color table per frame or if it changes the pixel data to force using the global color table. In my projects, I build a color table that can be used by the most frames and set that color table as global and tell each of those frames to use the global. For the remaining frames that cannot use it, they keep their local color table.
    In this example is created the palette for each frame. Just use oct-tree class, we can calculate the optimal palette for each frame and for entire animation.

  4. #4
    Member
    Join Date
    May 2013
    Posts
    47

    Re: [VB6] Creation of GIF-animation with the transparent background.

    can not used in xp, can you fixed?thanks!

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: [VB6] Creation of GIF-animation with the transparent background.

    It was already stated that this method doesn't work on XP...
    Yes, as far as i know it doesn't work in XP. I was having my own code for the creation GIF frame, but it's written on C++. Maybe ever i'll update this code. Honestly, it is old project, i just posted it here.

  6. #6

  7. #7
    Member
    Join Date
    May 2013
    Posts
    47

    Re: [VB6] Creation of GIF-animation with the transparent background.

    thank you @the trick !

  8. #8
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: [VB6] Creation of GIF-animation with the transparent background.

    does it work on xp yet
    Last edited by On Error Try Again; Jul 31st, 2016 at 02:41 PM.

  9. #9
    Fanatic Member
    Join Date
    Apr 2017
    Posts
    554

    Re: [VB6] Creation of GIF-animation with the transparent background.

    Don't you just hate it when someone says they'll do something and you never hear from them again
    Last edited by Code Dummy; Dec 26th, 2018 at 12:09 PM.

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: [VB6] Creation of GIF-animation with the transparent background.

    Don't know about that, but I sure do get aggravated by passive-aggressive voice.

    This is a forum of volunteers, many of whom are talented enough to be as busy as they want to be. People forget, or have other priorities, or just lose interest. There's no requirement on them, nor are they profiting from providing free code. You might ask them, if it matters that much.
    My usual boring signature: Nothing

  11. #11
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: [VB6] Creation of GIF-animation with the transparent background.

    Don't know about that, but I sure do get aggravated by passive-aggressive voice.

    This is a forum of volunteers, many of whom are talented enough to be as busy as they want to be. People forget, or have other priorities, or just lose interest. There's no requirement on them, nor are they profiting from providing free code. You might ask them, if it matters that much.
    My usual boring signature: Nothing

  12. #12

  13. #13
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: [VB6] Creation of GIF-animation with the transparent background.

    Is there any other way to create GIF with VB6 or vb.net?
    how to use、import .net frame method in vb6?

  14. #14
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    597

    Re: [VB6] Creation of GIF-animation with the transparent background.

    Quote Originally Posted by xiaoyao View Post
    Is there any other way to create GIF with VB6 or vb.net?
    how to use、import .net frame method in vb6?
    xiaoyao, don't abuse the thread with an irrelevant question.

  15. #15
    Member
    Join Date
    Apr 2009
    Posts
    48

    Re: [VB6] Creation of GIF-animation with the transparent background.

    I love how small the code is. Do you know how to load an image from an stdpicture or hWnd, and save to a byte array instead of a file?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width