Qt with openEXR and the code crashed
-
Hi everyone.
I'm writing an image viewer.
For EXR, I've compiled the source code to get:
bin, includes, libs and dlls.
The openEXR is compiled in x64 and the version is 3.
zlib is x64
Imath is x64
My Qt is x64 and the free version.In the pro file, I added:
LIBS += -l$$PWD/openEXR/lib/Iex-3_1_d
LIBS += -l$$PWD/openEXR/lib/IlmThread-3_1_d
LIBS += -l$$PWD/openEXR/lib/Imath-3_1_d
LIBS += -l$$PWD/openEXR/lib/OpenEXR-3_1_d
LIBS += -l$$PWD/openEXR/lib/OpenEXRUtil-3_1_d
INCLUDEPATH += $$PWD/openEXR/include/Imath
INCLUDEPATH += $$PWD/openEXR/include/openEXRMy test code:
openexrloader.h#ifndef OPENEXRLOADER_H #define OPENEXRLOADER_H #include <QWidget> #include <QtCore> #include <QtGui> #include <QImageIOPlugin> //Imath #include <half.h> //openEXR #include <OpenEXRConfig.h> #include <ImfRgbaFile.h> #include <ImfRgba.h> #include <ImfArray.h> //Namespace #include "namespaceAlias.h" class openEXRLoader:QObject { public: explicit openEXRLoader(); void writeRgba1 (const char fileName[], const IMF::Rgba *pixels, int width, int height); signals: }; #endif // OPENEXRLOADER_Hopenexrloader.cpp
#include "openexrloader.h" openEXRLoader::openEXRLoader():QObject() { const char fileName[] = "D:/test.exr"; //Declare a pointer in the memory for RGBA IMF::Rgba *pixels = NULL; int width = 100; int height = 100; try { writeRgba1(fileName, pixels, width, height); } catch (const std::exception &exc) { std::cerr << exc.what() << std::endl; } } void openEXRLoader::writeRgba1 (const char fileName[], const IMF::Rgba *pixels, int width, int height) { IMF::RgbaOutputFile file (fileName, width, height, IMF::WRITE_RGBA); // 1 file.setFrameBuffer (pixels, 1, width); // 2 file.writePixels (height); // 3 }NO errors, but the code will crash.
Which part do I did it incorrectly?
Thank you for help.
-
Hi everyone.
I'm writing an image viewer.
For EXR, I've compiled the source code to get:
bin, includes, libs and dlls.
The openEXR is compiled in x64 and the version is 3.
zlib is x64
Imath is x64
My Qt is x64 and the free version.In the pro file, I added:
LIBS += -l$$PWD/openEXR/lib/Iex-3_1_d
LIBS += -l$$PWD/openEXR/lib/IlmThread-3_1_d
LIBS += -l$$PWD/openEXR/lib/Imath-3_1_d
LIBS += -l$$PWD/openEXR/lib/OpenEXR-3_1_d
LIBS += -l$$PWD/openEXR/lib/OpenEXRUtil-3_1_d
INCLUDEPATH += $$PWD/openEXR/include/Imath
INCLUDEPATH += $$PWD/openEXR/include/openEXRMy test code:
openexrloader.h#ifndef OPENEXRLOADER_H #define OPENEXRLOADER_H #include <QWidget> #include <QtCore> #include <QtGui> #include <QImageIOPlugin> //Imath #include <half.h> //openEXR #include <OpenEXRConfig.h> #include <ImfRgbaFile.h> #include <ImfRgba.h> #include <ImfArray.h> //Namespace #include "namespaceAlias.h" class openEXRLoader:QObject { public: explicit openEXRLoader(); void writeRgba1 (const char fileName[], const IMF::Rgba *pixels, int width, int height); signals: }; #endif // OPENEXRLOADER_Hopenexrloader.cpp
#include "openexrloader.h" openEXRLoader::openEXRLoader():QObject() { const char fileName[] = "D:/test.exr"; //Declare a pointer in the memory for RGBA IMF::Rgba *pixels = NULL; int width = 100; int height = 100; try { writeRgba1(fileName, pixels, width, height); } catch (const std::exception &exc) { std::cerr << exc.what() << std::endl; } } void openEXRLoader::writeRgba1 (const char fileName[], const IMF::Rgba *pixels, int width, int height) { IMF::RgbaOutputFile file (fileName, width, height, IMF::WRITE_RGBA); // 1 file.setFrameBuffer (pixels, 1, width); // 2 file.writePixels (height); // 3 }NO errors, but the code will crash.
Which part do I did it incorrectly?
Thank you for help.