This class holds GIF encoder options.
Namespace:
Aurigma.GraphicsMill.Codecs
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
Public NotInheritable Class GifEncoderOptions _ Inherits EncoderOptions
public sealed class GifEncoderOptions : EncoderOptions
This class enables to initialize both entire GIF file and separate frames settings. Usually you can use this class from Saving event handler to modify both global and frames settings. If you set global settings for the same file multiple times, only settings specified at the first time are used.
This table gives the explanation for all GIF settings:
Property | Description |
---|---|
Delay (frame) | Specifies a delay of the frame (how long should it be displayed). |
DisposalMethod (frame) | Specifies a disposal method for the frame (what to do with the screen when new frame is being displayed). |
Interlaced (frame) | Specifies whether the frame should be interlaced. |
BackgroundEntryIndex (global) | Specifies an entry in the global palette which is treated as a background. |
GlobalPalette (global) | Specifies a global palette for entire GIF file. |
LocalPaletteEnabled (global) | Specifies whether to use local palettes for each frame or use global palette only. |
PlaybackCount (global) | Specifies how much times the GIF should be animated (or if it should be played infinitely). |
Width (global) | Specifies a width of the GIF file. If dimensions of frame is larger of GIF dimensions, frame bitmap is cropped. |
Height (global) | Specifies a height of the GIF file. If dimensions of frame is larger of GIF dimensions, frame bitmap is cropped. |
MediaFormat property of this class always returns value that equals to GifFormat static field of the FormatManager class. Left and Top are used to specify offset of the frame relatively top left corner of the GIF.
Let's assume that we want to load a JPEG file and save this image as a web-optimized GIF file (for example, reduce number of colors to 32). This code sample demonstrates how to do it:
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg") bitmap.ColorManagement.PaletteEntryCount = 32 bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, _ Nothing) bitmap.Save("C:\Mountain.gif", _ New Aurigma.GraphicsMill.Codecs.GifEncoderOptions) bitmap.Dispose()
using (Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg")) { bitmap.ColorManagement.PaletteEntryCount = 32; bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, null); bitmap.Save(@"C:\Mountain.gif", new Aurigma.GraphicsMill.Codecs.GifEncoderOptions()); }