Skip to content

Instantly share code, notes, and snippets.

@evilpilaf
Created July 27, 2020 15:52
Show Gist options
  • Save evilpilaf/b3ab64e44fdba3077e9073a53976cddf to your computer and use it in GitHub Desktop.
Save evilpilaf/b3ab64e44fdba3077e9073a53976cddf to your computer and use it in GitHub Desktop.
public MemoryStream MergeAsAnimation(IReadOnlyList<MemoryStream> images, ImageParametersBase imageParameters)
{
var memoryStream = new MemoryStream();
var encoderOptions = new SkGifEncoderOptions { RepeatCount = 0 };
using var encoder = new SkGifEncoder(memoryStream, encoderOptions);
foreach (var imageStream in images)
{
imageStream.Position = 0;
using var image = SKImage.FromEncodedData(imageStream);
var frameInfo = new SkGifEncoderFrameInfo
{
Duration = 500,
TransparentColor = SKColor.Empty
};
encoder.AddFrame(image, frameInfo);
}
memoryStream.Position = 0;
return memoryStream;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment