Exemplo n.º 1
0
        /// <summary>
        /// Returns the <see cref="JpegColorConverter"/> corresponding to the given <see cref="JpegColorSpace"/>
        /// </summary>
        public static JpegColorConverter GetConverter(JpegColorSpace colorSpace)
        {
            JpegColorConverter converter = Converters.FirstOrDefault(c => c.ColorSpace == colorSpace);

            if (converter == null)
            {
                throw new Exception($"Could not find any converter for JpegColorSpace {colorSpace}!");
            }

            return(converter);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JpegImagePostProcessor"/> class.
        /// </summary>
        /// <param name="memoryManager">The <see cref="MemoryManager"/> to use for buffer allocations.</param>
        /// <param name="rawJpeg">The <see cref="IRawJpegData"/> representing the uncompressed spectral Jpeg data</param>
        public JpegImagePostProcessor(MemoryManager memoryManager, IRawJpegData rawJpeg)
        {
            this.RawJpeg = rawJpeg;
            IJpegComponent c0 = rawJpeg.Components.First();

            this.NumberOfPostProcessorSteps = c0.SizeInBlocks.Height / BlockRowsPerStep;
            this.PostProcessorBufferSize    = new Size(c0.SizeInBlocks.Width * 8, PixelRowsPerStep);

            this.ComponentProcessors = rawJpeg.Components.Select(c => new JpegComponentPostProcessor(memoryManager, this, c)).ToArray();
            this.rgbaBuffer          = memoryManager.Allocate <Vector4>(rawJpeg.ImageSizeInPixels.Width);
            this.colorConverter      = ColorConverters.JpegColorConverter.GetConverter(rawJpeg.ColorSpace);
        }