Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用freeImage将UINT16单色图像转换为8位单色图像 < >我想将 uUT16单色图像转换为 8位图像,在C++中。p>_Image_Image Processing_Qt4_Freeimage - Fatal编程技术网

使用freeImage将UINT16单色图像转换为8位单色图像 < >我想将 uUT16单色图像转换为 8位图像,在C++中。p>

使用freeImage将UINT16单色图像转换为8位单色图像 < >我想将 uUT16单色图像转换为 8位图像,在C++中。p>,image,image-processing,qt4,freeimage,Image,Image Processing,Qt4,Freeimage,我有一张照片 char *buffer; 我想把新转换的缓冲区交给QImage(Qt) 我正在尝试使用freeImagePlus fipImage fimage; if (fimage.loadfromMemory(...) == false) //error loadfromMemory需要一个fipMemoryIO地址: loadfromMemory(fipmemoryo&memIO,int标志=0) 我也是 fipImage fimage; BYTE *buf = (BYTE*

我有一张照片

char *buffer;
我想把新转换的缓冲区交给QImage(Qt)

我正在尝试使用freeImagePlus

fipImage fimage;
if (fimage.loadfromMemory(...) == false)
    //error
loadfromMemory需要一个fipMemoryIO地址:

loadfromMemory(fipmemoryo&memIO,int标志=0)

我也是

fipImage fimage;
BYTE *buf = (BYTE*)malloc(gimage.GetBufferLength() * sizeof(BYTE));
// 'buf' is empty, I have to fill it with 'buffer' content
// how can I do it?
fipMemoryIO memIO(buf, gimage.GetBufferLength());

fimage.loadFromMemory(memIO);
if (fimage.convertTo8Bits() == true)
    cout << "Good";

我不明白什么是FREE_IMAGE_格式,这是这两个函数的第一个参数。我在freeImage文档中找不到这些类型的信息

那我就结束了

imageQt = new QImage(destiny, dimX, dimY, QImage::Format_Indexed8);
如何用初始缓冲区的内容填充“buf”

然后把图像中的数据转换成图像的uchar*数据


谢谢。

< P>在简单的C++中转换是简单的,不需要外部库,除非它们明显快,并且你关心这样的加速。下面是我将如何进行转换,至少作为第一次剪切。数据在输入缓冲区内转换,因为输出小于输入

QImage from16Bit(void * buffer, int width, int height) {
   int size = width*height*2; // length of data in buffer, in bytes
   quint8 * output = reinterpret_cast<quint8*>(buffer);
   const quint16 * input = reinterpret_cast<const quint16*>(buffer);
   if (!size) return QImage;
   do {
      *output++ = *input++ >> 8;
   } while (size -= 2);
   return QImage(output, width, height, QImage::Format_Indexed8);
}
QImage from16位(空*缓冲区、整型宽度、整型高度){
int size=width*height*2;//缓冲区中数据的长度,以字节为单位
quint8*output=重新解释强制转换(缓冲区);
常量quint16*输入=重新解释强制转换(缓冲区);
如果(!size)返回QImage;
做{
*输出+++=*输入+++>>8;
}而(尺寸-=2);
返回QImage(输出、宽度、高度、QImage::Format_Indexed8);
}
imageQt = new QImage(destiny, dimX, dimY, QImage::Format_Indexed8);
QImage from16Bit(void * buffer, int width, int height) {
   int size = width*height*2; // length of data in buffer, in bytes
   quint8 * output = reinterpret_cast<quint8*>(buffer);
   const quint16 * input = reinterpret_cast<const quint16*>(buffer);
   if (!size) return QImage;
   do {
      *output++ = *input++ >> 8;
   } while (size -= 2);
   return QImage(output, width, height, QImage::Format_Indexed8);
}