public override void InjectFrameData(JpegFrame frame, IRawJpegData jpegData) { this.frame = frame; var spectralComponents = new LibJpegTools.ComponentData[frame.ComponentCount]; for (int i = 0; i < spectralComponents.Length; i++) { JpegComponent component = frame.Components[i]; spectralComponents[i] = new LibJpegTools.ComponentData(component.WidthInBlocks, component.HeightInBlocks, component.Index); } this.spectralData = new LibJpegTools.SpectralData(spectralComponents); }
/// <summary> /// Initializes a new instance of the <see cref="JpegImagePostProcessor"/> class. /// </summary> /// <param name="configuration">The <see cref="Configuration"/> to configure internal operations.</param> /// <param name="rawJpeg">The <see cref="IRawJpegData"/> representing the uncompressed spectral Jpeg data</param> public JpegImagePostProcessor(Configuration configuration, IRawJpegData rawJpeg) { this.configuration = configuration; this.RawJpeg = rawJpeg; IJpegComponent c0 = rawJpeg.Components.First(); this.NumberOfPostProcessorSteps = c0.SizeInBlocks.Height / BlockRowsPerStep; this.PostProcessorBufferSize = new Size(c0.SizeInBlocks.Width * 8, PixelRowsPerStep); MemoryAllocator memoryAllocator = configuration.MemoryAllocator; this.ComponentProcessors = rawJpeg.Components.Select(c => new JpegComponentPostProcessor(memoryAllocator, this, c)).ToArray(); this.rgbaBuffer = memoryAllocator.Allocate <Vector4>(rawJpeg.ImageSizeInPixels.Width); this.colorConverter = JpegColorConverter.GetConverter(rawJpeg.ColorSpace); }
/// <summary> /// Initializes a new instance of the <see cref="JpegImagePostProcessor"/> class. /// </summary> /// <param name="configuration">The <see cref="Configuration"/> to configure internal operations.</param> /// <param name="rawJpeg">The <see cref="IRawJpegData"/> representing the uncompressed spectral Jpeg data</param> public JpegImagePostProcessor(IRawJpegData rawJpeg) { this.RawJpeg = rawJpeg; IJpegComponent c0 = rawJpeg.Components[0]; this.NumberOfPostProcessorSteps = c0.SizeInBlocks.Height / BlockRowsPerStep; this.PostProcessorBufferSize = new Size(c0.SizeInBlocks.Width * 8, PixelRowsPerStep); this.ComponentProcessors = new JpegComponentPostProcessor[rawJpeg.Components.Length]; for (int i = 0; i < rawJpeg.Components.Length; i++) { this.ComponentProcessors[i] = new JpegComponentPostProcessor(this, rawJpeg.Components[i]); } this.rgbaBuffer = MemoryGroup <Vector4> .Allocate(rawJpeg.ImageSizeInPixels.Width); this.colorConverter = JpegColorConverter.GetConverter(rawJpeg.ColorSpace, rawJpeg.Precision); }
public override void InjectFrameData(JpegFrame frame, IRawJpegData jpegData) { }
/// <inheritdoc/> protected override JpegColorConverter GetColorConverter(JpegFrame frame, IRawJpegData jpegData) => JpegColorConverter.GetConverter(JpegColorSpace.RGB, frame.Precision);
/// <summary> /// Initializes a new instance of the <see cref="JpegComponentPostProcessor"/> class. /// </summary> public JpegComponentPostProcessor(MemoryAllocator memoryAllocator, JpegFrame frame, IRawJpegData rawJpeg, Size postProcessorBufferSize, IJpegComponent component) { this.frame = frame; this.component = component; this.rawJpeg = rawJpeg; this.blockAreaSize = this.component.SubSamplingDivisors * 8; this.ColorBuffer = memoryAllocator.Allocate2DOveraligned <float>( postProcessorBufferSize.Width, postProcessorBufferSize.Height, this.blockAreaSize.Height); this.blockRowsPerStep = postProcessorBufferSize.Height / 8 / this.component.SubSamplingDivisors.Height; }
/// <summary> /// Gets the color converter. /// </summary> /// <param name="frame">The jpeg frame with the color space to convert to.</param> /// <param name="jpegData">The raw JPEG data.</param> /// <returns>The color converter.</returns> protected virtual JpegColorConverterBase GetColorConverter(JpegFrame frame, IRawJpegData jpegData) => JpegColorConverterBase.GetConverter(jpegData.ColorSpace, frame.Precision);
/// <summary> /// Injects jpeg image decoding metadata. /// </summary> /// <remarks> /// This is guaranteed to be called only once at SOF marker by <see cref="HuffmanScanDecoder"/>. /// </remarks> /// <param name="frame"><see cref="JpegFrame"/> instance containing decoder-specific parameters.</param> /// <param name="jpegData"><see cref="IRawJpegData"/> instance containing decoder-specific parameters.</param> public abstract void InjectFrameData(JpegFrame frame, IRawJpegData jpegData);
/// <summary> /// Gets the color converter. /// </summary> /// <param name="frame">The jpeg frame with the color space to convert to.</param> /// <param name="jpegData">The raw JPEG data.</param> /// <returns>The color converter.</returns> public virtual JpegColorConverter GetColorConverter(JpegFrame frame, IRawJpegData jpegData) => JpegColorConverter.GetConverter(jpegData.ColorSpace, frame.Precision);
internal JpegBitmapLoader(IRawJpegData rawData, int imageWidth, int imageHeight) { this.RawData = rawData; this.ImageHeight = imageHeight; this.ImageWidth = imageWidth; }