@mvsri said in QT QImage Read From Error:
image_path is nothing but a QString which stores the path to a bmp image in a folder. the path is static it doesn't change.
I know that! My question is about the content of that file.
I don't know whether the image writing is finished or not. that's why i used QFile exists to check if the file is created or not and read the image if the path exists.
But that doesn't tell you anything about whether it has started but not finished writing to that file, does it? (Unless you are relying on Windows or something not allowing a file to satisfy "exists" until it has been closed, which I would see as dodgy in the extreme.) In which case, you will read in an incomplete image file, maybe that's why you have "black" at the bottom? At least put in a qDebug() << image.sizeInBytes() after loading it (though I'm not sure if that's reliable)....
QFile::remove(image_path);
It gets worse! This, or renaming: how do you know that at the instant you execute this the camera has not re-started writing to that file for the next capture, and you are (trying to) removing/renaming a file while it is being written anew?
Is your camera-image-capture-write-to-file a separate process from your code? How do you know when the capture has started/finished writing to the file?