gpt4 book ai didi

opencv - “QImage with no type”编译错误消息

转载 作者:行者123 更新时间:2023-12-02 17:55:19 24 4
gpt4 key购买 nike

您好,有人可以帮我弄清楚如何解决此错误消息吗?我试图将Qt3工作代码重写为Qt4,以将IplImage转换为QImage,并找到“正确的转换类型”,但是下面的代码导致“ISO C++禁止声明没有类型的'QImage'”

....
QImage *qqImage;
if (this->data->nChannels == 1)
{

QVector<QRgb> myColorTable;
for (int i = 0; i < 256; i++)
myColorTable.push_back(qRgb(i, i, i)); //colorTable[i]);


qqImage = new QImage(qImageBuffer, width, height, QImage::Format_Indexed8);
}
else
{

qqImage = new QImage(qImageBuffer, width, height, QImage::Format_RGB32);

}

return qqImage;

最佳答案

下面的代码段可在我的Qt4应用程序上运行,请尝试一下。

    // img1 and img2 are Mat objects, img1 is grayscale,
// img2 is three channel RGB image

QImage qimg1,qimg2;

if (this->data->nChannels == 1){

qimg1=QImage(img1.data,img1.cols,img1.rows,QImage::Format_Indexed8);

}

else {

qimg2=QImage(img2.data,img2.cols,img2.rows,QImage::Format_RGB888);

}

关于opencv - “QImage with no type”编译错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6482252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com