gifencoder 0.2.2 copy "gifencoder: ^0.2.2" to clipboard
gifencoder: ^0.2.2 copied to clipboard

outdatedDart 1 only

A library for creating gif files, including animated gifs.

A gif encoder written in Dart.

Usage #

To create a regular GIF:

import 'dart:html';
import 'package:gifencoder/gifencoder.dart';

int width = ...;
int height = ...;
var ctx = new CanvasElement(width: width, height: height).context2D;
// draw your image in the canvas context
var data = ctx.getImageData(0, 0, width, height);
List<int> bytes = gifencoder.makeGif(width, height, data.data)

To create an animated Gif, use a GifBuffer instead:

int framesPerSecond = ...;
var frames = new gifencoder.GifBuffer(width, height);
for (var i = 0; i < myFrameCount; i++) {
  // draw the next frame on the canvas context
  frames.add(ctx.getImageData(0, 0, width, height).data);
}
List<int> bytes = frames.build(framesPerSecond);

Once you have the bytes of the GIF, you can save it somewhere or convert it into a data URL. See example/squares.dart for how to do that.

5
likes
0
pub points
34%
popularity

Publisher

unverified uploader

A library for creating gif files, including animated gifs.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on gifencoder