Solved QML Image: Error decoding: Unable to read image data
-
Please provide a download link for the jpg file.
-
@Anas_Deshmukh
show the cpp method implementation please.
Also how is this method called exactly (regarding thread safety)? -
@Anas_Deshmukh
Try figuring out the image format you are using. Try using any png file.. -
int ipCamera::capturePreviewImage1() { int ret; fileClass fileClass1; bool flag=fileClass1.fileExists("/home/user/ipcamera/previewImage/camera1.jpg"); if(flag) QFile::remove("/home/user/ipcamera/previewImage/camera1.jpg"); QString cameraIp="192.168.1.113"; QString command="wget -O /home/user/ipcamera/previewImage/camera1.jpg http://"+ cameraIp+"/snapshot.jpg?user=admin&pwd="; ret=system(qPrintable(command)); if(ret<0) { qDebug() << "system call for capturePreviewImage1 failed"; return ret; } QString permission="chmod -R 777 /home/user/ipcamera/previewImage/"; qDebug() << "change permission command : previewImage : " << permission; qDebug() << "previewImage1 end "; return 1; }```
-
@Wieland its ip camera . command i am using is :
wget -O /home/user/ipcamera/previewImage/camera1.jpg http://192.168.1.113/snapshot.jpg?user=admin&pwd=
-
@Anas_Deshmukh
File format in the header of image file might be different.
Open file with binary editor in Qt Creator. You should see actual file format of the image. Change format of your image to that format and you should not see any error.Usually jpeg file starts with 0xFF 0xD8 and ends with 0xFF 0xD9, which in your case showing as starting of your file.
And one more thing.. If image has wrong data, it wont effect other .qml file.
-
@Tirupathi-Korla thanks for note abt qt binary editor its good to learn, but in every scenario my file starts with 0xFF 0xD8 and ends with 0xFF 0xD9 (default jpeg).
If i open same file in other qml it open correctly, it seems with that perticular .qml file lead me err.
still trying to fix it... -
@Tirupathi-Korla file command output, i am sure image capture is not corrupted, still wondering why it not open in qml with err
Not a JPEG file: starts with 0xff 0xd9 qrc:/source/entry_INO.qml:4202:17: QML Image: Error decoding: file:///home/user/ipcamera/previewImage/camera1.jpeg: Unable to read image data
file command ouput :
file /home/user/ipcamera/previewImage/camera1.jpeg /home/user/ipcamera/previewImage/camera1.jpeg: JPEG image data, JFIF standard 1.01, baseline, precision 0, 4360x240
-
Hi everyone,
I put tiny delay between capture event and loading event.
in my code i figure out that i am loading before it get saved completely.nothing wrong with code, lesson learnt Never be so fast to access something before it finish first task.
thanks everyone :)
-
@mrjj monday syndrome cost me one sunday :(
issue is fixed fix now.