C# Класс ScreenToGif.Encoding.AnimatedGifEncoder

Animated Gif Encoder Class
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

AddFrame() публичный Метод

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
Результат bool

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

Finish() публичный Метод

Flushes any pending data and closes output file. If writing to an OutputStream, the stream is not closed.
public Finish ( ) : bool
Результат bool

SetDelay() публичный Метод

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
Результат void

SetDispose() публичный Метод

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.
Результат void

SetFrameRate() публичный Метод

Sets frame rate in frames per second. Equivalent to SetDelay(1000/fps).
public SetFrameRate ( float fps ) : void
fps float Frame rate (frames per second)
Результат void

SetQuality() публичный Метод

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.
Результат void

SetRepeat() публичный Метод

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.
Результат void

SetSize() публичный Метод

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.
Результат void

SetTransparent() публичный Метод

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.
Результат void

Start() публичный Метод

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.
Результат bool

Start() публичный Метод

Initiates writing of a GIF file with the specified name.
public Start ( String file ) : bool
file String String containing output file name.
Результат bool

StringToByteArray() публичный статический Метод

Converts a String to a byte Array.
public static StringToByteArray ( String hex ) : byte[]
hex String The string to convert
Результат byte[]