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 justQImage::save
orQPixmap::save
:
QImageWriter writer("/tmp/test.jpg");
if(!writer.write(pixmap.toImage()))
{
qDebug() << writer.errorString();
}