Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
 /// </summary>
 /// <param name="memoryManager">The <see cref="MemoryManager"/> to use for buffer allocations.</param>
 /// <param name="options">The options for the encoder.</param>
 public GifEncoderCore(MemoryManager memoryManager, IGifEncoderOptions options)
 {
     this.memoryManager  = memoryManager;
     this.textEncoding   = options.TextEncoding ?? GifConstants.DefaultEncoding;
     this.quantizer      = options.Quantizer;
     this.ignoreMetadata = options.IgnoreMetadata;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
 /// </summary>
 /// <param name="memoryAllocator">The <see cref="MemoryAllocator"/> to use for buffer allocations.</param>
 /// <param name="options">The options for the encoder.</param>
 public GifEncoderCore(MemoryAllocator memoryAllocator, IGifEncoderOptions options)
 {
     this.memoryAllocator = memoryAllocator;
     this.textEncoding    = options.TextEncoding ?? GifConstants.DefaultEncoding;
     this.quantizer       = options.Quantizer;
     this.colorTableMode  = options.ColorTableMode;
 }
Beispiel #3
0
        /// <summary>
        /// Encodes the image to the specified stream from the <see cref="Image{TColor}"/>.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="image">The <see cref="Image{TColor}"/> to encode from.</param>
        /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
        /// <param name="options">The options for the encoder.</param>
        public void Encode <TColor>(Image <TColor> image, Stream stream, IGifEncoderOptions options)
            where TColor : struct, IPixel <TColor>
        {
            GifEncoderCore encoder = new GifEncoderCore(options);

            encoder.Encode(image, stream);
        }
Beispiel #4
0
        /// <inheritdoc/>
        public void Encode <TColor>(Image <TColor> image, Stream stream, IEncoderOptions options)
            where TColor : struct, IPixel <TColor>
        {
            IGifEncoderOptions gifOptions = GifEncoderOptions.Create(options);

            this.Encode(image, stream, gifOptions);
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
 /// </summary>
 /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
 /// <param name="options">The options for the encoder.</param>
 public GifEncoderCore(Configuration configuration, IGifEncoderOptions options)
 {
     this.configuration   = configuration;
     this.memoryAllocator = configuration.MemoryAllocator;
     this.quantizer       = options.Quantizer;
     this.colorTableMode  = options.ColorTableMode;
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
 /// </summary>
 /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
 /// <param name="options">The options for the encoder.</param>
 public GifEncoderCore(Configuration configuration, IGifEncoderOptions options)
 {
     this.configuration         = configuration;
     this.memoryAllocator       = configuration.MemoryAllocator;
     this.quantizer             = options.Quantizer;
     this.colorTableMode        = options.ColorTableMode;
     this.pixelSamplingStrategy = options.GlobalPixelSamplingStrategy;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
        /// </summary>
        /// <param name="options">The options for the encoder.</param>
        public GifEncoderCore(IGifEncoderOptions options)
        {
            this.textEncoding = options.TextEncoding ?? GifConstants.DefaultEncoding;

            this.quantizer      = options.Quantizer;
            this.threshold      = options.Threshold;
            this.paletteSize    = options.PaletteSize;
            this.ignoreMetadata = options.IgnoreMetadata;
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
 /// </summary>
 /// <param name="options">The options for the encoder.</param>
 public GifEncoderCore(IGifEncoderOptions options)
 {
     this.options = options ?? new GifEncoderOptions();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GifEncoderCore"/> class.
 /// </summary>
 /// <param name="memoryAllocator">The <see cref="MemoryAllocator"/> to use for buffer allocations.</param>
 /// <param name="options">The options for the encoder.</param>
 public GifEncoderCore(MemoryAllocator memoryAllocator, IGifEncoderOptions options)
 {
     this.memoryAllocator = memoryAllocator;
     this.quantizer       = options.Quantizer;
     this.colorTableMode  = options.ColorTableMode;
 }
Beispiel #10
0
        /// <summary>
        /// Saves the image to the given stream with the gif format.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="stream">The stream to save the image to.</param>
        /// <param name="options">The options for the encoder.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
        /// <returns>
        /// The <see cref="Image{TColor}"/>.
        /// </returns>
        public static Image <TColor> SaveAsGif <TColor>(this Image <TColor> source, Stream stream, IGifEncoderOptions options)
            where TColor : struct, IPixel <TColor>
        {
            GifEncoder encoder = new GifEncoder();

            encoder.Encode(source, stream, options);

            return(source);
        }