Hey!
Create your own animated gif files with this library.
The code is easy to use and to understand.
The library files and sample are delivered in the attachments.
Credits:
NOTE:
My BitCloud library is not included. This is just used to write an bytearray to a file from the outputstream.
There are some examples to write a bytearray to a file on the forums.
Tomas
Create your own animated gif files with this library.
The code is easy to use and to understand.
The library files and sample are delivered in the attachments.
- RSAnimatedGifEncoder
Properties:- Delay As
Sets the delay time between each frame, or changes it for subsequent frames
(applies to last frame added). - Dispose As
Sets the GIF frame disposal code for the last added frame and any
subsequent frames. Default is 0 if no transparent color has been set,
otherwise 2. - FrameRate As
Sets frame rate in frames per second. Equivalent to
<code>setDelay(1000/fps)</code>. - Quality As
Sets quality of color quantization (conversion of images to the maximum 256
colors allowed by the GIF specification). Lower values (minimum = 1)
produce better colors, but slow processing significantly. 10 is the
default, and produces good color mapping at reasonable speeds. Values
greater than 20 do not yield significant improvements in speed. - Repeat As
Sets the number of times the set of GIF frames should be played. Default is
1; 0 means play indefinitely. Must be invoked before the first image is
added. - Transparent As
Sets the transparent color for the last added frame and any subsequent
frames. Since all colors are subject to modification in the quantization
process, the color in the final palette for each frame closest to the given
color becomes the transparent color for that frame. May be set to null to
indicate no transparent color.
- addFrame (im As Bitmap) As Boolean
Adds next GIF frame. The frame is not written immediately, but is actually
deferred until the next frame is received so that timing data can be
inserted. Invoking <code>finish()</code> flushes all frames. If
<code>setSize</code> was not invoked, the size of the first image is used
for all subsequent frames.
im: BufferedImage containing frame to write.
Return type: @return:true if successful. - finish As Boolean
Flushes any pending data and closes output file. If writing to an
OutputStream, the stream is not closed. - setPosition (x As Int, y As Int)
Sets the GIF frame position. The position is 0,0 by default.
Useful for only updating a section of the image
w: int frame width.
h: int frame width. - setSize (w As Int, h As Int)
Sets the GIF frame size. The default size is the size of the first frame
added if this method is not invoked.
w: int frame width.
h: int frame width. - start (os As OutputStream) As Boolean
Initiates GIF file creation on the given stream. The stream is not closed
automatically.
os: OutputStream on which GIF images are written.
Return type: @return:false if initial write failed.
- Delay As
Credits:
As for the original version, code is free for any kind of usages, but you must refer to the Unisys LZW patent for restrictions on use of the associated LZWEncoder class.
NOTE:
My BitCloud library is not included. This is just used to write an bytearray to a file from the outputstream.
There are some examples to write a bytearray to a file on the forums.
Tomas
Attachments
Last edited: