Recent

Author Topic: [SOLVED] Is there a Way to Save Animated GIFs?  (Read 1597 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
[SOLVED] Is there a Way to Save Animated GIFs?
« on: October 13, 2019, 04:20:45 pm »
Is there a Way to Save Animated GIFs?
Maybe a library or package
« Last Edit: October 16, 2019, 02:28:00 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 3279
    • Lainz
Re: Is there a Way to Save Animated GIFs?
« Reply #1 on: October 13, 2019, 04:25:08 pm »
BGRABitmap can save Gif, you maybe can look how it's done inside LazPaint for example.

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: Is there a Way to Save Animated GIFs?
« Reply #2 on: October 13, 2019, 04:41:01 pm »
BGRABitmap can save Gif, you maybe can look how it's done inside LazPaint for example.

I am aware that it can save a GIF.

But what about an Animated GIF... you know, multiple images into one animated gif.
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 3279
    • Lainz
Re: Is there a Way to Save Animated GIFs?
« Reply #3 on: October 13, 2019, 04:49:18 pm »
BGRABitmap can save Gif, you maybe can look how it's done inside LazPaint for example.

I am aware that it can save a GIF.

But what about an Animated GIF... you know, multiple images into one animated gif.

It can save a gif with multiple frames, try opening an animated gif, select a frame and edit it, then save. The frame is saved inside the animated gif. So it can.

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: Is there a Way to Save Animated GIFs?
« Reply #4 on: October 13, 2019, 05:23:33 pm »
BGRABitmap can save Gif, you maybe can look how it's done inside LazPaint for example.

I am aware that it can save a GIF.

But what about an Animated GIF... you know, multiple images into one animated gif.

It can save a gif with multiple frames, try opening an animated gif, select a frame and edit it, then save. The frame is saved inside the animated gif. So it can.

Okay.. will check it out. thanks
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: Is there a Way to Save Animated GIFs?
« Reply #5 on: October 13, 2019, 05:44:33 pm »
BGRABitmap can save Gif, you maybe can look how it's done inside LazPaint for example.

I am aware that it can save a GIF.

But what about an Animated GIF... you know, multiple images into one animated gif.

It can save a gif with multiple frames, try opening an animated gif, select a frame and edit it, then save. The frame is saved inside the animated gif. So it can.

Okay, tried it.

1) When I open a gif, it shows me all frames in a popup window, but I can only choose one
And it loads just one fram into one layer.

2) If I load two frames, one-by-one, I can have multiple layers
But, when I save it as an animated gif there is no animating

What am i missing?
« Last Edit: October 13, 2019, 10:56:15 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 3279
    • Lainz
Re: Is there a Way to Save Animated GIFs?
« Reply #6 on: October 13, 2019, 11:36:01 pm »
What am i missing?

Reading the source code? I created this snippet only with the information given at lazpaint procedure TLazPaintImage.UpdateGifFileUTF8(AFilename: string;
  AOutputFilename: string); 

Code: Pascal  [Select]
  1. var
  2.   gif : TBGRAAnimatedGif;
  3.   bmp: TBGRABitmap;
  4. begin
  5.   bmp := TBGRABitmap.Create(100,100,BGRAWhite);
  6.   bmp.FontHeight := 30;
  7.   bmp.TextRect(Rect(0,0,100,100), 'Hello', taCenter, tlCenter, BGRABlack);
  8.  
  9.   gif := TBGRAAnimatedGif.Create;
  10.   gif.SetSize(100,100);
  11.   gif.LoopCount:=100;
  12.   gif.AddFullFrame(bmp, 500);
  13.  
  14.   bmp.Fill(BGRAWhite);
  15.   bmp.TextRect(Rect(0,0,100,100), 'World', taCenter, tlCenter, BGRABlack);
  16.  
  17.   gif.AddFullFrame(bmp, 500);
  18.   gif.SaveToFile('image.gif');
  19.   gif.Free;
  20.  
  21.   bmp.Free;

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: Is there a Way to Save Animated GIFs?
« Reply #7 on: October 14, 2019, 02:30:01 am »
What am i missing?

Reading the source code? I created this snippet only with the information given at lazpaint procedure TLazPaintImage.UpdateGifFileUTF8(AFilename: string;
  AOutputFilename: string); 


Thanks Lainz

I didn't read the code because LAZPaint wasn't creating an Animated gif (with layers) from the way I was using it.
That's why i ask "What am I Missing".

Why wasn't LAZPaint working by opening, adding two images (as Layers) and save as Animated Gif?
I didn't see any other way to make LAZ Paint work out of the box.

Thanks for the code, that seems pretty easy.

Just one q:
How do I set the frame length for each frame in miliseconds or seconds?
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 3279
    • Lainz
Re: Is there a Way to Save Animated GIFs?
« Reply #8 on: October 14, 2019, 02:50:28 am »
Yes is planned to do the saving from the layers to animations.

But it can open a gif and save the frame into the same animated gif. That's from where I get the code.

The second parameter of addfullframe sets the frame duration.

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: Is there a Way to Save Animated GIFs?
« Reply #9 on: October 14, 2019, 02:57:46 am »
Yes is planned to do the saving from the layers to animations.

But it can open a gif and save the frame into the same animated gif. That's from where I get the code.

The second parameter of addfullframe sets the frame duration.

Okay...


What does this do. I stumbled across this

gif.AverageDelayMs

Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

circular

  • Hero Member
  • *****
  • Posts: 3022
    • Personal webpage
Re: Is there a Way to Save Animated GIFs?
« Reply #10 on: October 14, 2019, 11:32:48 pm »
It returns the average of the frame durations in the file. It gives you an idea of the speed
Conscience is the debugger of the mind

winni

  • Sr. Member
  • ****
  • Posts: 437
Re: Is there a Way to Save Animated GIFs?
« Reply #11 on: October 15, 2019, 06:25:12 pm »
Hi!

Creating an amimated GIF with BGRA - that's cool.

In the Gimp this a lot of tricky handicraft. And in BGRA it's such easy!

Thank you circular!

Winni

circular

  • Hero Member
  • *****
  • Posts: 3022
    • Personal webpage
Re: [SOLVED] Is there a Way to Save Animated GIFs?
« Reply #12 on: October 16, 2019, 03:31:46 pm »
You’re welcome  :)

Next step maybe is to provide optimisations of GIF. Some files where only a small part of the image change could be smaller.
Conscience is the debugger of the mind