public TiffPaletteWriter(
            ImageFrame <TPixel> image,
            IQuantizer quantizer,
            MemoryAllocator memoryAllocator,
            Configuration configuration,
            TiffEncoderEntriesCollector entriesCollector,
            int bitsPerPixel)
            : base(image, memoryAllocator, configuration, entriesCollector)
        {
            DebugGuard.NotNull(quantizer, nameof(quantizer));
            DebugGuard.NotNull(configuration, nameof(configuration));
            DebugGuard.NotNull(entriesCollector, nameof(entriesCollector));
            DebugGuard.MustBeBetweenOrEqualTo(bitsPerPixel, 4, 8, nameof(bitsPerPixel));

            this.BitsPerPixel      = bitsPerPixel;
            this.maxColors         = this.BitsPerPixel == 4 ? 16 : 256;
            this.colorPaletteSize  = this.maxColors * 3;
            this.colorPaletteBytes = this.colorPaletteSize * 2;
            using IQuantizer <TPixel> frameQuantizer = quantizer.CreatePixelSpecificQuantizer <TPixel>(this.Configuration, new QuantizerOptions()
            {
                MaxColors = this.maxColors
            });
            this.quantizedImage = frameQuantizer.BuildPaletteAndQuantizeFrame(image, image.Bounds());

            this.AddColorMapTag();
        }
        public static TiffBaseColorWriter <TPixel> Create <TPixel>(
            TiffPhotometricInterpretation?photometricInterpretation,
            ImageFrame <TPixel> image,
            IQuantizer quantizer,
            MemoryAllocator memoryAllocator,
            Configuration configuration,
            TiffEncoderEntriesCollector entriesCollector,
            int bitsPerPixel)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            switch (photometricInterpretation)
            {
            case TiffPhotometricInterpretation.PaletteColor:
                return(new TiffPaletteWriter <TPixel>(image, quantizer, memoryAllocator, configuration, entriesCollector, bitsPerPixel));

            case TiffPhotometricInterpretation.BlackIsZero:
            case TiffPhotometricInterpretation.WhiteIsZero:
                if (bitsPerPixel == 1)
                {
                    return(new TiffBiColorWriter <TPixel>(image, memoryAllocator, configuration, entriesCollector));
                }

                return(new TiffGrayWriter <TPixel>(image, memoryAllocator, configuration, entriesCollector));

            default:
                return(new TiffRgbWriter <TPixel>(image, memoryAllocator, configuration, entriesCollector));
            }
        }
 protected TiffCompositeColorWriter(ImageFrame <TPixel> image, MemoryAllocator memoryAllocator, Configuration configuration, TiffEncoderEntriesCollector entriesCollector)
     : base(image, memoryAllocator, configuration, entriesCollector)
 {
 }
Beispiel #4
0
 public TiffBiColorWriter(ImageFrame <TPixel> image, MemoryAllocator memoryAllocator, Configuration configuration, TiffEncoderEntriesCollector entriesCollector)
     : base(image, memoryAllocator, configuration, entriesCollector)
 {
     // Convert image to black and white.
     this.imageBlackWhite = new Image <TPixel>(configuration, new ImageMetadata(), new[] { image.Clone() });
     this.imageBlackWhite.Mutate(img => img.BinaryDither(KnownDitherings.FloydSteinberg));
 }
Beispiel #5
0
 public TiffRgbWriter(ImageFrame <TPixel> image, MemoryAllocator memoryAllocator, Configuration configuration, TiffEncoderEntriesCollector entriesCollector)
     : base(image, memoryAllocator, configuration, entriesCollector)
 {
 }
Beispiel #6
0
 protected TiffBaseColorWriter(ImageFrame <TPixel> image, MemoryAllocator memoryAllocator, Configuration configuration, TiffEncoderEntriesCollector entriesCollector)
 {
     this.Image            = image;
     this.MemoryAllocator  = memoryAllocator;
     this.Configuration    = configuration;
     this.EntriesCollector = entriesCollector;
 }