C# Class ScreenToGif.FileWriters.GifWriter.AnimatedGifEncoder

Animated Gif Encoder Class
Inheritance: IDisposable
Afficher le fichier Open project: dbremner/ScreenToGif Class Usage Examples

Méthodes publiques

Méthode Description
AddFrame ( Image im, int x, int y ) : bool

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 finish() flushes all frames. If setSize was not invoked, the size of the first image is used for all subsequent frames.

Dispose ( ) : void
Finish ( ) : bool

Flushes any pending data and closes output file. If writing to an OutputStream, the stream is not closed.

SetDelay ( int ms ) : void

Sets the delay time between each frame, or changes it for subsequent frames (applies to last frame added).

SetDispose ( int code ) : void

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.

SetFrameRate ( float fps ) : void

Sets frame rate in frames per second. Equivalent to SetDelay(1000/fps).

SetQuality ( int quality ) : void

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.

SetRepeat ( int iter ) : void

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.

SetSize ( int w, int h ) : void

Sets the GIF frame size. The default size is the size of the first frame added if this method is not invoked.

SetTransparent ( Color c ) : void

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.

Start ( FileStream os ) : bool

Initiates GIF file creation on the given stream. The stream is not closed automatically.

Start ( String file ) : bool

Initiates writing of a GIF file with the specified name.

StringToByteArray ( String hex ) : byte[]

Converts a String to a byte Array.

Private Methods

Méthode Description
AnalyzePixels ( ) : void

Analyzes image colors and creates color map.

FindClosest ( Color c ) : int

Returns index of palette color closest to given color.

GetImagePixels ( ) : void

Extracts image pixels into byte array "pixels".

WriteComment ( string comment ) : void

Writes the comment for the animation.

WriteGraphicCtrlExt ( ) : void

Writes Graphic Control Extension.

WriteImageDesc ( int width, int heigth, int x, int y ) : void

Writes Image Descriptor.

WriteLsd ( ) : void

Writes Logical Screen Descriptor

WriteNetscapeExt ( ) : void

Writes Netscape application extension to define the repeat count.

WritePalette ( ) : void

Writes color table.

WritePixels ( int width, int height ) : void

Encodes and writes pixel data.

WriteShort ( int value ) : void

Write 16-bit value to output stream, LSB first.

WriteString ( String s ) : void

Writes string to output stream.

Method Details

AddFrame() public méthode

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 finish() flushes all frames. If setSize was not invoked, the size of the first image is used for all subsequent frames.
public AddFrame ( Image im, int x, int y ) : bool
im Image BufferedImage containing frame to write.
x int The horizontal position of the frame
y int The vertical position of the frame
Résultat bool

Dispose() public méthode

public Dispose ( ) : void
Résultat void

Finish() public méthode

Flushes any pending data and closes output file. If writing to an OutputStream, the stream is not closed.
public Finish ( ) : bool
Résultat bool

SetDelay() public méthode

Sets the delay time between each frame, or changes it for subsequent frames (applies to last frame added).
public SetDelay ( int ms ) : void
ms int Delay time in milliseconds
Résultat void

SetDispose() public méthode

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.
public SetDispose ( int code ) : void
code int Disposal code.
Résultat void

SetFrameRate() public méthode

Sets frame rate in frames per second. Equivalent to SetDelay(1000/fps).
public SetFrameRate ( float fps ) : void
fps float Frame rate (frames per second)
Résultat void

SetQuality() public méthode

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.
public SetQuality ( int quality ) : void
quality int Quality value greater than 0.
Résultat void

SetRepeat() public méthode

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.
public SetRepeat ( int iter ) : void
iter int Number of iterations.
Résultat void

SetSize() public méthode

Sets the GIF frame size. The default size is the size of the first frame added if this method is not invoked.
public SetSize ( int w, int h ) : void
w int The frame width.
h int The frame weight.
Résultat void

SetTransparent() public méthode

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.
public SetTransparent ( Color c ) : void
c Color Color to be treated as transparent on display.
Résultat void

Start() public méthode

Initiates GIF file creation on the given stream. The stream is not closed automatically.
public Start ( FileStream os ) : bool
os System.IO.FileStream OutputStream on which GIF images are written.
Résultat bool

Start() public méthode

Initiates writing of a GIF file with the specified name.
public Start ( String file ) : bool
file String String containing output file name.
Résultat bool

StringToByteArray() public static méthode

Converts a String to a byte Array.
public static StringToByteArray ( String hex ) : byte[]
hex String The string to convert
Résultat byte[]