如何在C#中从JPEG提取量化矩阵 [英] How to extract quantization matrices from a JPEG in C#
本文介绍了如何在C#中从JPEG提取量化矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在C#中提取JPG文件的量化矩阵?我已经找到了libjpeg.NET,但是我不知道如何检索QT矩阵.请在下面找到我的代码.
Is it possible to extract the quantization matrices of a JPG file in C#? I have found the libjpeg.NET but I cannot figure out how to retrieve the QTs matrices. Please find below my code.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitMiracle.LibJpeg;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
string file = @"PATH_TO_FILE";
JpegImage img = new JpegImage(file);
Console.Read();
// Ideally, there should be some img.GetQuantizationMatrix() method
}
}
}
推荐答案
如果您只想使用量化表(别无其他),只需扫描JPEG流中的DQT标记即可(FFDB后面跟着一个2字节长)并提取值.
If you just want the quantization tables (and nothing else), it is a simple matter to scan the JPEG stream for the DQT marker (FFDB-followed by a 2-byte length) and extract the values.
您无需解码图像即可获取此信息.
You do not need to decode the image to get this information.
这篇关于如何在C#中从JPEG提取量化矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文