简体   繁体   中英

Qt open image from file - how to know image size

I am getting image file with QFileDialog. Image can be in different standard image file extensions. How can I get image size (width and height)?

If you only need the size of the image, but not the image itself, it is better to use the QImageReader. As described in the wiki , not all image data is loaded. This procedure should be much faster:

QImageReader reader("image.png");
QSize sizeOfImage = reader.size();
int height = sizeOfImage.height();
int width = sizeOfImage.width();

从检索到的文件名创建一个 QPixmap 并调用QPixmap::size()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM