我有一些遗留代码正在写入 NITF 文件以显示一些图像。在旧代码中,似乎使用了 LUT,并且有一段代码一次将一行写入 NITF 文件,并且该行的值是这样计算的:
// convert RGB to LUT values
unsigned char *lutData = new unsigned char[numBytes/3];
for (unsigned j = 0 ; j < numBytes/3 ; j++)
lutData[j] = (unsigned char) stuff;
data 是我原始的无符号字符数组。
所以现在我正在尝试获取该数据数组并将其输出到我的 GUI 中的 QImage 中。
在我看来,在 NITF 中,有一块 LUT 数据的大小为“行 x 列”,对吧?所以我创建了一个 lu 数据数组:
unsigned char *lutData = new unsigned char[imwidth * imheight];
QImage *qi = new QImage(imwidth,imheight, QImage::Format_Indexed8);
for (int i = 0 ; i < imheight ; i++)
{
#pragma omp parallel for
for (int j = 0 ; j < imwidth ; j++)
{
lutData[i*imwidth + j] = stuff;
}
}
然后我尝试像这样填充 qimage:
for (int i = 0 ; i < imheight ; i++)
{
#pragma omp parallel for
for (int j = 0 ; j < imwidth ; j++)
{
qi->setPixel(j,i,qRgb(lutData[i*imwidth + j],lutData[i*imwidth + j],lutData[i*imwidth + j]));
}
}
但是,这似乎或多或少只是给了我一个灰度图像,而不是我的实际数据。
我究竟做错了什么?
谢谢!