Qt- unable to save jpeg files

前端 未结 4 2069
遥遥无期
遥遥无期 2021-01-06 05:28

I am trying to save images in Qt. I am able to save all the formats except jpeg. I have the following libraries under the plugins/imageformats folder.

libqgif.so,

相关标签:
4条回答
  • 2021-01-06 06:17

    You might find what the problem is by:

    • 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();
      }
      
    0 讨论(0)
  • 2021-01-06 06:17

    Under windows the qjpeg4.dll must in a imageformats directory under the application's directory by default.

    0 讨论(0)
  • 2021-01-06 06:22

    Try adding the following line to your main:

    QApplication::addLibraryPath( <path to directory containing libjpeg.so> );
    
    0 讨论(0)
  • 2021-01-06 06:23

    Check if the linking in the .so files are proper.

    0 讨论(0)
提交回复
热议问题