Issues with loadFromData function in QImage
-
@Nick-Redwill said in Issues with loadFromData function in QImage:
filename.toStdWString().c_str()
This doesn't look quite right.
PS.
Nor does this:
frame->picture().data()
wrote on 2 Jan 2022, 20:37 last edited by@kshegunov said in Issues with loadFromData function in QImage:
This doesn't look quite right.
This code works fine. Its just convert qstring to wstring and then to wchar_t *. This part works identical in both applications.
The problem occurs on the line with loadFromData function.
-
@kshegunov said in Issues with loadFromData function in QImage:
This doesn't look quite right.
This code works fine. Its just convert qstring to wstring and then to wchar_t *. This part works identical in both applications.
The problem occurs on the line with loadFromData function.
@Nick-Redwill said in Issues with loadFromData function in QImage:
Its just convert qstring to wstring and then to wchar_t *
No it's not. After the conversion from
QString
towstring
you're taking a pointer to a temporary. -
@Nick-Redwill said in Issues with loadFromData function in QImage:
Its just convert qstring to wstring and then to wchar_t *
No it's not. After the conversion from
QString
towstring
you're taking a pointer to a temporary.wrote on 2 Jan 2022, 21:07 last edited by@kshegunov said in Issues with loadFromData function in QImage:
No it's not. After the conversion from QString to wstring you're taking a pointer to a temporary.
Okay, I'll fix this later. It doesn't matter now. The problem is in another part of the code.
-
wrote on 2 Jan 2022, 21:48 last edited by Nick Redwill 1 Feb 2022, 21:50
I also noticed, that in application where code doesn't work occurs warning:
libpng warning: ICCP: known incorrect sRGB profile
Its occurs right after loadFromData function call.
-
I also noticed, that in application where code doesn't work occurs warning:
libpng warning: ICCP: known incorrect sRGB profile
Its occurs right after loadFromData function call.
wrote on 2 Jan 2022, 21:53 last edited by@Nick-Redwill Google
libpng warning: ICCP: known incorrect sRGB profile
-
wrote on 3 Jan 2022, 15:27 last edited by
QByteArray bytes (pic.data(), pic.size()); QFile file ("test.png"); file.open(QIODevice::WriteOnly); file.write(bytes); file.close(); if (coverImg.load("test.png")) { qDebug() << "Image loaded!"; } else { qDebug() << "Error image!"; }
I changed the code to this and it also doesn't work in one project and works in another. Moreover, the file in both projects is created correctly (i can open it using the windows image viewer). The libpng warning is still displayed.
-
wrote on 3 Jan 2022, 15:44 last edited by
Why does QImage behave differently in different projects?
-
QByteArray bytes (pic.data(), pic.size()); QFile file ("test.png"); file.open(QIODevice::WriteOnly); file.write(bytes); file.close(); if (coverImg.load("test.png")) { qDebug() << "Image loaded!"; } else { qDebug() << "Error image!"; }
I changed the code to this and it also doesn't work in one project and works in another. Moreover, the file in both projects is created correctly (i can open it using the windows image viewer). The libpng warning is still displayed.
@Nick-Redwill said in Issues with loadFromData function in QImage:
I changed the code to this and it also doesn't work in one project and works in another.
What means 'does not work'.
Please proper error description... -
wrote on 3 Jan 2022, 18:18 last edited by
I solved the problem! I just needed to add the imageformats folder with dll files to the exe file folder.
-
I solved the problem! I just needed to add the imageformats folder with dll files to the exe file folder.
@Nick-Redwill This is what windeployqt is for...
14/14