若该文为原创文章,未经允许不得转载
原博主博客地址:https://blog.csdn.net/qq21497936
原博主博客导航:https://blog.csdn.net/qq21497936/article/details/102478062
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/85042037
各位读者,知识无穷而人力有穷,要么改需求,要么找专业人士,要么自己研究
红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…(点击传送门)
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");
测试结果
拓展
原博主博客地址:https://blog.csdn.net/qq21497936
原博主博客导航:https://blog.csdn.net/qq21497936/article/details/102478062
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/85042037