gifencoder 0.2.3

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.

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  gifencoder: "^0.2.3"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:gifencoder/gifencoder.dart';

Platforms

About

A library for creating gif files, including animated gifs.

Author

Brian Slesinsky

Homepage

github.com/google/dart-gif-encoder

Documentation

www.dartdocs.org/documentation/gifencoder/0.2.3/

Uploader

bslesinsky@gmail.com

License

Apache 2.0 (LICENSE)

Published

Jul 28, 2013