Create a Gif file, but this is not a loop

I am using the GifBitmapEncoder class to generate a gif file. Create success, but it's not a Loop.

my code:

private string[] _files = null;
private void CreateGifFile()
{
    if (_files != null && _files.Length != 0)
    {
        GifBitmapEncoder gEncoder = new GifBitmapEncoder();
        _files.ToList().ForEach((a) =>
        {
            Bitmap bitmap = new Bitmap(a);
            var src = Imaging.CreateBitmapSourceFromHBitmap
            (
                    bitmap.GetHbitmap(),
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions()
            );
            gEncoder.Frames.Add(BitmapFrame.Create(src));
        });

        using (var fileStream = new FileStream ("1.gif", FileMode.Create))
        {
            gEncoder.Save(fileStream);
        }
    }
}

      

+3
c # gif


source to share


No one has answered this question yet

Check out similar questions:

1786
How to create Excel file (.XLS and .XLSX) in C # without installing Microsoft Office?
1106
Create a generic method limiting T to Enum
1012
Can you view all the enumeration values?
506
PNG vs. GIF vs. JPEG vs. SVG - When is the Best Time to Use?
4
Swift - create GIF from images and turn it into NSData
3
How do I implement android groid encoder in my app?
2
Create control in foreach loop?
1
Android is the best way to convert .gif to .png
0
Convert image list to GIf
0
How to make two .gif files one file?



All Articles
Loading...
X
Show
Funny
Dev
Pics