Qt实用技巧:使用Qt加载超大图片的耗时测试

需求

        某机器人项目中,需要加载构建的地图,此处仅测试直接加载图片的时间。

 

相关博客

《QT三大绘图类:QPixmap/QImage/QPicture》:https://blog.csdn.net/qq21497936/article/details/79231365

 

测试代码

QString path;
path = "./map/1.png";
QFileInfo fileInfo;

fileInfo.setFile(path);
qDebug() << __FILE__ << __LINE__ << "Load file:" << path << " size:" << fileInfo.size();
qDebug() << __FILE__ << __LINE__ << "QImage start load, " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
if(!_image.load(path))
{
    qDebug() << __FILE__ << __LINE__ << "Failed to QImage load path:" << path;
}
qDebug() << __FILE__ << __LINE__ << "QImage end load,   " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
qDebug() << __FILE__ << __LINE__ << "QPixmap start load," 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
if(!_pixmap.load(path))
{
    qDebug() << __FILE__ << __LINE__ << "Failed to QPixmap load path:" << path;
}
qDebug() << __FILE__ << __LINE__ << "QPixmap end load,  " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");

path = "./map/2.png";
fileInfo.setFile(path);
qDebug() << __FILE__ << __LINE__ << "Load file:" << path << " size:" << fileInfo.size();
qDebug() << __FILE__ << __LINE__ << "QImage start load, " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
if(!_image.load(path))
{
    qDebug() << __FILE__ << __LINE__ << "Failed to QImage load path:" << path;
}
qDebug() << __FILE__ << __LINE__ << "QImage end load,   " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
qDebug() << __FILE__ << __LINE__ << "QPixmap start load," 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
if(!_pixmap.load(path))
{
    qDebug() << __FILE__ << __LINE__ << "Failed to QPixmap load path:" << path;
}
qDebug() << __FILE__ << __LINE__ << "QPixmap end load,  " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");

path = "./map/3.pgm";
fileInfo.setFile(path);
qDebug() << __FILE__ << __LINE__ << "Load file:" << path << " size:" << fileInfo.size();
qDebug() << __FILE__ << __LINE__ << "QImage start load, " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
if(!_image.load(path))
{
    qDebug() << __FILE__ << __LINE__ << "Failed to QImage load path:" << path;
}
qDebug() << __FILE__ << __LINE__ << "QImage end load,   " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
qDebug() << __FILE__ << __LINE__ << "QPixmap start load," 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");
if(!_pixmap.load(path))
{
    qDebug() << __FILE__ << __LINE__ << "Failed to QPixmap load path:" << path;
}
qDebug() << __FILE__ << __LINE__ << "QPixmap end load,  " 
         << QDateTime::currentDateTime().toString("hh:MM:ss:zzz");

 

测试结果

        Qt实用技巧:使用Qt加载超大图片的耗时测试_第1张图片

 

拓展

        Qt实用技巧:使用Qt加载超大图片的耗时测试_第2张图片

你可能感兴趣的:(Qt开发专栏,C++,#,Qt实用技巧,图形图像)