Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update GIFEncoder.js

Added Comment Extension Block
  • Loading branch information...
commit 5fb18aa981be6efd82d65fd8d533093d360132c0 1 parent 650aea5
@tobozo tobozo authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 GIFEncoder.js
View
31 GIFEncoder.js
@@ -64,6 +64,7 @@
/*private*/ var firstFrame/*Boolean*/ = true;
/*private*/ var sizeSet/*Boolean*/ = false; // if false, get size from first frame
/*private*/ var sample/*int*/ = 10; // default sample interval for quantizer
+ /*private*/ var comment/*string*/ = "Generated by jsgif (https://github.com/antimatter15/jsgif/)"; // default comment for generated gif
/**
* Sets the delay time between each frame, or changes it for subsequent frames
@@ -129,6 +130,19 @@
}
+
+ /**
+ * Sets the comment for the block comment
+ * @param
+ * string to be insterted as comment
+ */
+ var setComment = exports.setComment = function setComment(c/*string*/)
+ {
+ comment = c;
+ }
+
+
+
/**
* The addFrame method takes an incoming BitmapData object to create each frames
* @param
@@ -168,6 +182,9 @@
}
writeGraphicCtrlExt(); // write graphic control extension
+ if(comment!='') {
+ writeCommentExt(); // write comment extension
+ }
writeImageDesc(); // image descriptor
if (!firstFrame) writePalette(); // local color table
writePixels(); // encode and write pixel data
@@ -436,6 +453,20 @@
}
/**
+ * Writes Comment Extention
+ */
+ var writeCommentExt = function writeCommentExt()/*void*/
+ {
+
+ out.writeByte(0x21); // extension introducer
+ out.writeByte(0xfe); // comment label
+ out.writeByte(comment.length); // Block Size (s)
+ out.writeUTFBytes(comment);
+ out.writeByte(0); // block terminator
+ }
+
+
+ /**
* Writes Image Descriptor
*/
Please sign in to comment.
Something went wrong with that request. Please try again.