嵌入式linux--电子相册
2017-07-09 09:54
274 查看
实验内容与要求:采用QT开发技术,在物联网实验箱上实现一个电子相框,系统上电启动后自动启动此电子相框程序。程序自动读取U盘中的所有图片,并自动按照5秒一张的时间间隔播放。图片自动在显示屏全屏显示(不能变形)。所有图片自动循环播放。如果没有插入U盘或U盘中没有图片,则界面上提示没有可播放的图片。要求支持jpg、jpeg、gif、png、bmp等常见格式的图片。可以加入图片切换时的特效功能。
特色功能:点击屏幕显示暂停按钮和关闭按钮 再次点击即可隐藏
PS:自动启动需要改系统脚本
![](https://img-blog.csdn.net/20170709094205312?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3Nzc0MjE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](https://img-blog.csdn.net/20170709094218708?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3Nzc0MjE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](https://img-blog.csdn.net/20170709094234027?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3Nzc0MjE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](https://img-blog.csdn.net/20170709094245292?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3Nzc0MjE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
完整工程下载:http://download.csdn.net/detail/qq_29777421/9892855
特色功能:点击屏幕显示暂停按钮和关闭按钮 再次点击即可隐藏
PS:自动启动需要改系统脚本
//formphoto.cpp #include "formphoto.h" #include "ui_formphoto.h" #include <QDirIterator> #include <QDir> #include <QFileInfo> #include <QDesktopWidget> //#include <QGraphicsOpacityEffect> FormPhoto::FormPhoto(QWidget *parent) : QWidget(parent), ui(new Ui::FormPhoto) { ui->setupUi(this); this->Init(); } FormPhoto::~FormPhoto() { delete ui; } void FormPhoto::Init() { width = QApplication::desktop()->width(); height = QApplication::desktop()->height(); ui->scrollArea -> setFrameShape(QFrame::NoFrame); ui->scrollArea -> resize(width,height); ui->scrollArea -> setAlignment(Qt::AlignCenter); ui->imageLabel -> resize(width,height); ui->imageLabel -> setAlignment(Qt::AlignCenter); ui->showbutton -> setStyleSheet("QToolButton{background: transparent;}"); ui->showbutton -> resize(width,height); ui->playorstop -> setGeometry(QRect(QPoint(width/2-25, height/2-25), QSize(50, 50))); ui->playorstop -> setStyleSheet("QToolButton{background: transparent;}"); ui->playorstop -> setVisible(false); ui->close-> setGeometry(QRect(QPoint(width-70,5), QSize(30, 30))); ui->close -> setStyleSheet("QToolButton{background: transparent;}"); ui->close -> setVisible(false); currentNo = 0; imageNum = 0; isplaying = true; imagePixmap.load(":/image/MainPage.jpg"); imagePixmap = imagePixmap.scaled(width,height,Qt::IgnoreAspectRatio); ui->imageLabel->setPixmap(imagePixmap); timerfordelay=new QTimer; connect(timerfordelay,SIGNAL(timeout()),this,SLOT(hasImages())); timerfordelay->start(2000); timer=new QTimer; connect(timer,SIGNAL(timeout()),this,SLOT(playImageSlot())); timer->start(5000); //timerforfade = new QTimer; } void FormPhoto::hasImages() { timerfordelay->stop(); this -> getImages("/udisk/image"); if(!imageNum) { QMessageBox message(QMessageBox::Warning,NULL,"<font size='26' color='black'>U盘中无图片</font>", QMessageBox::Retry | QMessageBox::Cancel, NULL); message.setButtonText (QMessageBox::Retry,QString("重试")); message.setButtonText (QMessageBox::Cancel,QString("退出")); switch(message.exec()){ case QMessageBox::Retry: this->hasImages();break; case QMessageBox::Cancel: app->quit();break; } } else this -> playImageSlot(); } void FormPhoto::playImageSlot() { if(currentNo>=imageNum) currentNo=0; QString fileName=imageArrary[currentNo++]; if(isgif[currentNo-1] == true){ QMovie *movie = new QMovie(fileName); ui->imageLabel->setMovie(movie); movie->start(); } else{ imagePixmap.load(fileName); imagePixmap = imagePixmap.scaled(width,height,Qt::KeepAspectRatio); ui->imageLabel->setPixmap(imagePixmap); } // opacity=0; // this->fade_on_fade_in(); // connect(timerforfade,SIGNAL(timeout()),this,SLOT(fade_on_fade_in())); // timerforfade->start(50); } void FormPhoto::getImages(QString _dir) { QFileInfo dir(_dir); if(!dir.isDir()){ QMessageBox message(QMessageBox::Warning,NULL,"<font size='26' color='black'>请插入U盘</font>", QMessageBox::Retry | QMessageBox::Cancel, NULL); message.setButtonText (QMessageBox::Retry,QString("重试")); message.setButtonText (QMessageBox::Cancel,QString("退出")); switch(message.exec()){ case QMessageBox::Retry: this->getImages(_dir);break; case QMessageBox::Cancel: app->quit();break; } } else{ QDirIterator it(_dir,QDir::Files|QDir::Dirs|QDir::NoDotAndDotDot); while (it.hasNext())//存在 { QString name = it.next();//读取 QFileInfo info(name); if (info.isDir())//判断是目录 { this->getImages(name);//递归 } else { if (info.suffix() == "jpg" || info.suffix() == "bmp" || info.suffix() == "png" || info.suffix() == "gif" || info.suffix() == "jpeg") { if(info.suffix()=="gif") isgif[imageNum] = true; else isgif[imageNum] = false; imageArrary[imageNum++]=name;//符合添加 } } } } } void FormPhoto::on_showbutton_clicked() { if(ui->playorstop->isHidden()){ ui->playorstop->setVisible(true); ui->close->setVisible(true); } else{ ui->playorstop->setVisible(false); ui->close->setVisible(false); } } void FormPhoto::on_playorstop_clicked() { if(isplaying){ this->timer->stop(); isplaying = false; ui->playorstop->setIcon(QPixmap(":/image/play.png")); } else{ this->timer->start(5000); isplaying = true; ui->playorstop->setIcon(QPixmap(":/image/stop.png")); } } void FormPhoto::on_close_clicked() { app->quit(); } //void FormPhoto::fade_on_fade_in() //{ if(opacity==1.0) // { // this->timerforfade->stop();//定时器停止 // } // else // { // QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;; // effect->setOpacity(opacity); // ui->imageLabel->setGraphicsEffect(effect); // } // opacity+=0.01;//透明度累加 //}
完整工程下载:http://download.csdn.net/detail/qq_29777421/9892855
相关文章推荐
- 【EVB-335X-II试用体验】 基于Yocto的嵌入式的敏捷项目开发:以电子相册为例
- NEC电子与MontaVista就嵌入式Linux展开全面合作
- 嵌入式开发第20、21、22、23天(触摸屏电子相册)
- 基于S3C2451的嵌入式电子相册
- 嵌入式多功能电子相册之上位机
- Ubuntu16.04安装配置嵌入式交叉编译工具链arm-linux-gcc
- eclipse在进行linux嵌入式开发时环境变量的设置问题
- 嵌入式linux启动信息完全注释(网摘)
- 在ARM开发板的嵌入式linux系统上运行的QT程序,必须得要在linux里用QT编吗
- linux -- 嵌入式Linux下3G无线上网卡的驱动
- 电子专业(嵌入式)常见单词(二)
- 嵌入式linux学习计划第二阶段总结
- 嵌入式Linux之我行——Linux-2.6.30.4在2440上的移植之内核
- 嵌入式Linux开发培训资料整理
- 那些嵌入式(linux)
- 嵌入式Linux驱动学习之路(一)嵌入式系统的软硬件架构
- 学习嵌入式Linux的笔记和体会
- 嵌入式 Linux线…
- 〔转贴〕如何在嵌入式LINUX中增加自己的设备驱动程序
- 嵌入式系统Linux内核开发工程师必须掌握的三十道题