当前位置: 首页 > wzjs >正文

网站建设的特点设计师个人网站

网站建设的特点,设计师个人网站,一起做网店官网app,电子商务网站界面设计目录 图片处理器PictureEdit1 创建工具栏2 打开图片3 显示图片4 灰度处理5 颜色反转6 马赛克 图片处理器PictureEdit 创建工程&#xff0c;添加资源文件 1 创建工具栏 widget.h中 #include <QWidget> #include<QPixmap> #include<QFileDialog> #include&l…

目录

  • 图片处理器PictureEdit
  • 1 创建工具栏
  • 2 打开图片
  • 3 显示图片
  • 4 灰度处理
  • 5 颜色反转
  • 6 马赛克

图片处理器PictureEdit

创建工程,添加资源文件

image-20230904144039679

1 创建工具栏

  • widget.h
#include <QWidget>
#include<QPixmap>
#include<QFileDialog>
#include<QAction>
#include<QToolBar>
#include<QIcon>class QToolBar;
private:void createTollBar();private:QPixmap pic;QToolBar * toolBar;
  • widget.cpp
Widget::Widget(QWidget *parent): QWidget(parent)
{this->createTollBar();this->resize(400,500);
}
  • 添加按钮及图标
void Widget::createTollBar()
{this->toolBar = new QToolBar(this);//打开图片QAction *openAct = new QAction(QIcon("://Icon/open.png"),"打开图片");this->toolBar->addAction(openAct);//还原QAction *recoverAct = new QAction(QIcon("://Icon/recover.png"),"还原图片");this->toolBar->addAction(recoverAct);//灰图QAction *grayAct = new QAction(QIcon("://Icon/gray.png"),"灰图处理");this->toolBar->addAction(grayAct);//反转QAction *invertnAct = new QAction(QIcon("://Icon/Invert colors.png"),"颜色反转");this->toolBar->addAction(invertnAct);//模糊QAction *blurAct = new QAction(QIcon("://Icon/blurring.png"),"模糊处理");this->toolBar->addAction(blurAct);//马赛克QAction *mosaicAct = new QAction(QIcon("://Icon/mosaic.png"),"马赛克处理");this->toolBar->addAction(mosaicAct);//水墨QAction *inkAct = new QAction(QIcon("://Icon/ink painting.png"),"水墨处理");this->toolBar->addAction(inkAct);
}

image-20230904144248136

2 打开图片

  • widget.h中添加槽
public slots:void openPic();
  • widget.cpp中实现
void Widget::openPic()
{QString filePath = QFileDialog::getOpenFileName(this,"打开图片","./","image(*.png *.jpg *.bmp");this->pic = QPixmap(filePath);this->resize(this->pic.size());
}
  • 然后在createToolBar函数中连接
    //打开图片QAction *openAct = new QAction(QIcon("://Icon/open.png"),"打开图片");//连接信号connect(openAct,&QAction::triggered,this,&Widget::openPic);this->toolBar->addAction(openAct);

image-20230904150102099

不过此时添加后图片还无法显示

3 显示图片

  • widget.h中重写画图的虚函数
protected://重写虚函数void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
  • widget.cpp
void Widget::paintEvent(QPaintEvent *event)
{//显示在当前窗口QPainter p(this);//绘制图片p.drawPixmap(0,0,this->pic.width(),this->pic.height(),this->pic);QWidget::paintEvent(event);
}

image-20230904151536324

4 灰度处理

  • widget.h
    void grayPic();
  • widget.cpp
void Widget::grayPic()
{QImage image = this->pic.toImage();image.convertToFormat(QImage::Format_ARGB32);//转换成ARGB32以方便设置颜色//分辨遍历长和宽,因为图片长方形for(int i=0; i<=image.width();i++){for(int j=0;j<image.height();j++){//每个像素点都修改QRgb pixel = image.pixel(i,j);//平均值int avg = qGray(pixel);image.setPixel(i,j,qRgb(avg,avg,avg));}}this->pic = QPixmap::fromImage(image);//重新画图this->update();
}
  • createToolBar函数,连接信号
    //灰图QAction *grayAct = new QAction(QIcon("://Icon/gray.png"),"灰图处理");connect(grayAct,&QAction::triggered,this,&Widget::grayPic);this->toolBar->addAction(grayAct);

image-20230904152803901

5 颜色反转

  • widget.h
    void invertnPic();
  • widget.cpp
void Widget::invertnPic()
{QImage image = this->pic.toImage();image.convertToFormat(QImage::Format_ARGB32);//转换成ARGB32以方便设置颜色//分辨遍历长和宽,因为图片长方形for(int i=0; i<=image.width();i++){for(int j=0;j<image.height();j++){//每个像素点都修改QColor pixel = image.pixelColor(i,j);int r = pixel.red();int g = pixel.green();int b = pixel.blue();QColor newColor((255-r),(255,g),(255-b));image.setPixelColor(i,j,newColor);}}this->pic = QPixmap::fromImage(image);//重新画图this->update();
}
  • createToolBar函数,连接信号
    //反转QAction *invertnAct = new QAction(QIcon("://Icon/Invert colors.png"),"颜色反转");connect(invertnAct,&QAction::triggered,this,&Widget::invertnPic);this->toolBar->addAction(invertnAct);

image-20230904154033208

6 马赛克

  • widget.h
    void mosaicPic();
  • widget.cpp
void Widget::mosaicPic()
{QImage image = this->pic.toImage();image.convertToFormat(QImage::Format_ARGB32);//转换成ARGB32以方便设置颜色//分辨遍历长和宽,因为图片长方形int w = image.width()%SIZE;int h = image.height()%SIZE;for(int i=0; i<=image.width()-w;i+=SIZE){for(int j=0;j<image.height()-h;j+=SIZE){//每个像素点都修改int r=0,g=0,b=0;for(int m = i;m<i+SIZE;m++){for(int n = j;n<j+SIZE;n++){QColor c = image.pixelColor(m,n);r+=c.red();g+=c.green();b+=c.blue();}}QColor newColor(r/(SIZE*SIZE),g/(SIZE*SIZE),b/(SIZE*SIZE));for(int m = i;m<i+SIZE;m++){for(int n = j;n<j+SIZE;n++){image.setPixelColor(m,n,newColor);}}}}this->pic = QPixmap::fromImage(image);//重新画图this->update();
}
  • createToolBar函数,连接信号
    //马赛克QAction *mosaicAct = new QAction(QIcon("://Icon/mosaic.png"),"马赛克处理");connect(mosaicAct,&QAction::triggered,this,&Widget::mosaicPic);this->toolBar->addAction(mosaicAct);

image-20230904162403774

  • createToolBar函数,连接信号
    //马赛克QAction *mosaicAct = new QAction(QIcon("://Icon/mosaic.png"),"马赛克处理");connect(mosaicAct,&QAction::triggered,this,&Widget::mosaicPic);this->toolBar->addAction(mosaicAct);

[外链图片转存中…(img-xxswHv9g-1696602317319)]


文章转载自:

http://Hhyj18c7.mcwrg.cn
http://8wz8jYIi.mcwrg.cn
http://XR3MZa9G.mcwrg.cn
http://2epEs9jt.mcwrg.cn
http://cVABfkvh.mcwrg.cn
http://2qh2RN0X.mcwrg.cn
http://uLqyPLFR.mcwrg.cn
http://1G29fraP.mcwrg.cn
http://T3dTSkWr.mcwrg.cn
http://5WSlUafC.mcwrg.cn
http://TrqK14HQ.mcwrg.cn
http://T6abUNP2.mcwrg.cn
http://vC0OKIeA.mcwrg.cn
http://HoS6UDwF.mcwrg.cn
http://WiefaFdL.mcwrg.cn
http://6Gunb2gs.mcwrg.cn
http://D0wdv9BC.mcwrg.cn
http://6neOfUie.mcwrg.cn
http://tMOfTXW7.mcwrg.cn
http://BZasjaes.mcwrg.cn
http://SHLnPNDj.mcwrg.cn
http://4co3qGxS.mcwrg.cn
http://8ZCQZNgx.mcwrg.cn
http://MBGRqzXL.mcwrg.cn
http://UbybLzAq.mcwrg.cn
http://oJy4P5CJ.mcwrg.cn
http://Ofsz2Z2X.mcwrg.cn
http://03E0NspY.mcwrg.cn
http://EOkJDNJO.mcwrg.cn
http://UaqZt6Ff.mcwrg.cn
http://www.dtcms.com/wzjs/683465.html

相关文章:

  • 深圳建设执业注册中心网站泰安人才网档案查询
  • 企业网站的劣势重庆做网站泉州公司
  • 运城建网站中装建设吧
  • 有做二手厨房设备的网站吗罗湖网站制作费用
  • 公众号里的电影网站怎么做上海消费品网络营销推广公司
  • 网站设计联系网站建设教程免费夕滋湖南岚鸿官网
  • 网站建设外包word页面设计模板
  • 深圳p2p网站开发设计制作小车
  • 网站建设服务网络服务锦州网站建设
  • 西安网站建设 至诚wordpress 上传svg
  • 南湖网站建设公司常州建设网站
  • 商城网站制作公司地址东莞网站设计价格
  • 网站定制开发加公众号设计网站做海报
  • 电信网站开发语言主要用什么网站开发设计思路
  • 做网站的具体内容北京发布最新消息今天
  • 营销网站建设网站制作公司国内正规的现货交易平台
  • 门户网站开发源代码国内吃瓜爆料黑料网曝门
  • 惠安建设局网站企业网站建设套餐费用
  • 宁夏建设工程质量监督站网站高校网站首页设计
  • 网站客户留言asp网站 并发数
  • 网站开发公司巨推网站建设的目标和需求分析
  • 西部数码 网站建设高端网吧电脑配置清单
  • 网站过度优化个人简历模板下载 免费完整版
  • 滑县网站建设服务怎么增加网站首页权重
  • 求个网站你会感谢我的批量外链工具
  • 企业网站源码进一品资源网wordpress如何防注入
  • 软文写作公司搜索引擎关键词优化
  • wordpress的tag函数使用教程点击seo软件
  • 做网站的硬件和软件环境产品推销
  • 做企业网站要用什么软件h5商城网站是什么