QImage A::IplImage2QImage(const IplImage *iplImage)
{
    int height = iplImage->height;
    int width = iplImage->width; 
    if (iplImage->depth == IPL_DEPTH_8U && iplImage->nChannels == 3) {
        const uchar *qImageBuffer = (const uchar*)iplImage->imageData;
        QImage img(qImageBuffer, width, height, QImage::Format_RGB888); 
        return img.rgbSwapped();
    }
    else {
        // qWarning() << "Image cannot be converted.";  
        return QImage();
    }
}

void A::getFrame()
{
    commentsTextBox->setText("getFrame");
    if (VI.isFrameNew(device1)) {
        VI.getPixels(device1, (unsigned char *)frame->imageData, false, true);
    }
    QImage qimg2 = IplImage2QImage(frame);
    m_Label->setPixmap(QPixmap::fromImage(qimg2));
    if (!qimg2.isNull()) {
        x = qimg2.save("C:\\Data\\test.jpg");
        commentsTextBox->append("notEmpty33"); 
    }
}

 

 

    • Setting the environment variable QT_DEBUG_PLUGINS to 1 before running your application. 
      It will print the plugin loading attempts/successes/failures on the console.

    • Using a QImageWriter to get a more explicit error message than with just QImage::save or QPixmap::save :

QImageWriter writer("/tmp/test.jpg");
if(!writer.write(pixmap.toImage()))
{
    qDebug() << writer.errorString();
}

 

相关文章:

  • 2021-04-30
  • 2021-11-10
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-11-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-04-11
  • 2021-10-13
  • 2022-12-23
  • 2021-06-21
相关资源
相似解决方案