omggif

Haxe externs for `omggif` javascript library. Reader and writer for GIF images.
https://github.com/yar3333/haxe-omggif

To install, run:

haxelib install omggif 0.9.0 

See using Haxelib in Haxelib documentation for more information.

README.md

haxe externs for omggif library

Reader and writer for GIF images.

  • Original library: https://github.com/deanm/omggif/
  • Typescript definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/omggif/

Install

if you prefer to use building system like webpack

npm install omggif

In haxe code hxnodejs must be defined (use hxnodejs library or define that by -D compiler switch).

if you want to use library in html page directrly

Load js library by any way:

    <script src="omggif.js"></script>

Directly use js.omggif.* classes in your haxe code.

Using

read GIF

final gif = GifReader.fromBytes(catGifAsBytes);
trace("width =" + gif.width);
trace("height = " + gif.height);
trace("numFrames = " + gif.numFrames());
trace("loopCount = " + gif.loopCount()); // 0 = infinity

final data = new Uint8Array(gif.width * gif.height * 4);
gif.decodeAndBlitFrameRGBA(0, data); // read frame 0 as RGBA values

generate GIF

final width = 2;
final height = 2;

final buffer = new Array<Int>();

final gif = new GifWriter(buffer, width, height, { palette: [0xff0000, 0x0000ff] });
gif.addFrame(0, 0, width, height, [0, 1, 1, 0]); // position, size and pixel data (palette indexes)
final bytesCount = gif.end();

trace("bytesCount = " + bytesCount);
Contributors
yar3333
Version
0.9.0
Published
2 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub