I have a custom file format which stores some images. I load these images into memory during the operation of my program. The images are loaded in binary format (i.e. the same way they would appear on disk). I know what format the images are in (pretty much all jpeg). The problem is that I dont know the width/height, but I want to display the images without writing them to some temp file on disk. Anyone know how to do this?
Share
You can get the size of a qIcon using actual size
http://qt-project.org/doc/qt-5.0/qicon.html#actualSize
You shouldn’t have to write anything to disk, you just need to read your binary into something like QIcon, so that you can use QTs methods to get the width and height of the image. You just need to get the data into one of QTs data structures.
Check out QImage and QPixmap, I think they have methods for reading in binary. Or you can check this SO post here: QImage from unsigned char buffer (jpg format)