public JpegFrameContext(byte quality, ushort height, ushort width, JpegQuantizationTable luminance = null, JpegQuantizationTable chrominance = null, byte[] hSampFactor = null, byte[] vSampFactor = null) { Quality = quality; Height = height; Width = width; HSampFactor = hSampFactor ?? FrameDefaults.HSampFactor; VSampFactor = vSampFactor ?? FrameDefaults.VSampFactor; Luminance = luminance ?? JpegQuantizationTable.K1Luminance; Chrominance = chrominance ?? JpegQuantizationTable.K2Chrominance; DCT = new DCT(Quality, Luminance, Chrominance); HuffmanTable = HuffmanTable.GetHuffmanTable(null); JpegFrame = new JpegFrame(); JpegFrame.ScanLines = height; JpegFrame.SamplesPerLine = width; JpegFrame.Precision = 8; // Number of bits per sample JpegFrame.ComponentCount = FrameDefaults.NumberOfComponents; // Number of components (Y, Cb, Cr) var qTables = new JpegQuantizationTable[2]; qTables[0] = JpegQuantizationTable.GetJpegQuantizationTable(DCT.quantum[0]); qTables[1] = JpegQuantizationTable.GetJpegQuantizationTable(DCT.quantum[1]); for (byte i = 0; i < FrameDefaults.NumberOfComponents; i++) { JpegFrame.AddComponent(FrameDefaults.CompId[i], HSampFactor[i], VSampFactor[i], qTables[FrameDefaults.QtableNumber[i]]); JpegFrame.SetHuffmanTables(FrameDefaults.CompId[i], JpegFrame.AcTables[FrameDefaults.ACtableNumber[i]], JpegFrame.DcTables[FrameDefaults.DCtableNumber[i]]); } }
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); }
public override void InjectFrameData(JpegFrame frame, IRawJpegData jpegData) { }
/// <inheritdoc/> protected override JpegColorConverter GetColorConverter(JpegFrame frame, IRawJpegData jpegData) => JpegColorConverter.GetConverter(JpegColorSpace.RGB, frame.Precision);