Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ended up modifying <a href="http://www.codeproject.com/KB/GDI-plus/NGif.aspx" rel="noreferrer">http://www.codeproject.com/KB/GDI-plus/NGif.aspx</a> code to get what I needed and it worked! :)</p> <p>for the gif source file handling I added this method:</p> <pre><code> private bool AddGifFrames(Image image) { // implementation var fd = new FrameDimension(image.FrameDimensionsList[0]); int frameCount = image.GetFrameCount(fd); var frames = new List&lt;Tuple&lt;int, Image&gt;&gt;(); if (frameCount &gt; 1) { frames = new List&lt;Tuple&lt;int, Image&gt;&gt;(); //0x5100 is the property id of the GIF frame's durations //this property does not exist when frameCount &lt;= 1 byte[] times = image.GetPropertyItem(0x5100).Value; for (int i = 0; i &lt; frameCount; i++) { //selects GIF frame based on FrameDimension and frameIndex image.SelectActiveFrame(fd, i); //length in milliseconds of display duration int length = BitConverter.ToInt32(times, 4 * i); //save currect image frame as new bitmap frames.Add(new Tuple&lt;int, Image&gt;(length, new Bitmap(image))); } } // Not animated foreach (var frame in frames) { HandleFrame(frame.Item2, frame.Item1); } return true; } </code></pre> <p>and as for the custom delays I've modified this method:</p> <pre><code> protected void WriteGraphicCtrlExt(int? delay) { Fs.WriteByte(0x21); // extension introducer Fs.WriteByte(0xf9); // GCE label Fs.WriteByte(4); // data block size int transp, disp; if (Transparent == Color.Empty) { transp = 0; disp = 0; // dispose = no action } else { transp = 1; disp = 2; // force clear if using transparent color } if (Dispose &gt;= 0) { disp = Dispose &amp; 7; // user override } disp &lt;&lt;= 2; // packed fields Fs.WriteByte(Convert.ToByte(0 | // 1:3 reserved disp | // 4:6 disposal 0 | // 7 user input - 0 = none transp)); // 8 transparency flag WriteShort(delay ?? Delay); // delay x 1/100 sec Fs.WriteByte(Convert.ToByte(TransIndex)); // transparent color index Fs.WriteByte(0); // block terminator } </code></pre> <p>to sum it up - this code can add a gif as a frame by splitting it to frames and adding them, and it can also add custom delays.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload