Permalink
Browse files

added test for dynamic gif stack and test data

  • Loading branch information...
1 parent 45a7ddb commit 944d7ae58e2347fc6653effcb1d2ae3185368077 @pkrumins committed Jul 27, 2010
View
@@ -0,0 +1,30 @@
+var GifLib = require('gif');
+var fs = require('fs');
+var sys = require('sys');
+var Buffer = require('buffer').Buffer;
+
+var gifStack = new GifLib.DynamicGifStack('rgba');
+
+function rectDim(fileName) {
+ var m = fileName.match(/^\d+-rgba-(\d+)-(\d+)-(\d+)-(\d+).dat$/);
+ var dim = [m[1], m[2], m[3], m[4]].map(function (n) {
+ return parseInt(n, 10);
+ });
+ return { x: dim[0], y: dim[1], w: dim[2], h: dim[3] }
+}
+
+var files = fs.readdirSync('./push-data');
+
+files.forEach(function(file) {
+ var dim = rectDim(file);
+ var rgba = fs.readFileSync('./push-data/' + file);
+ gifStack.push(rgba, dim.x, dim.y, dim.w, dim.h);
+});
+
+fs.writeFileSync('dynamic.gif', gifStack.encode(), 'binary');
+
+var dims = gifStack.dimensions();
+
+sys.log("GIF located at (" + dims.x + "," + dims.y + ") with width " +
+ dims.width + " and height " + dims.height);
+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 944d7ae

Please sign in to comment.