实现图片的镜像功能
其他具体的代码基础看前面:http://blog.csdn.net/cutter_point/article/details/42839071
槽函数:
void ShowMirrorVertical(); //垂直镜像 void ShowMirrorHorizontal(); //水平镜像
相应的响应连接
//实现图像镜像的动作 //纵向 mirrorVerticalAction = new QAction(QIcon("mirrorVertical.png"), tr("mirrorVertical"), this); mirrorVerticalAction->setStatusTip(tr("mirrorVertical the image")); connect(mirrorVerticalAction, SIGNAL(triggered()), this, SLOT(ShowMirrorVertical())); //横向 mirrorHorizontalAction = new QAction(QIcon("mirrorHorizontal.png"), tr("mirrorHorizontal"), this); mirrorHorizontalAction->setStatusTip(tr("mirrorHorizontal the image")); connect(mirrorHorizontalAction, SIGNAL(triggered()), this, SLOT(ShowMirrorHorizontal()));
槽函数的实现:
//水平镜像 void ImageProcessor::ShowMirrorVertical() { if(img.isNull()) return; img = img.mirrored(true, false); //水平镜像 showWidget->imageLabel->setPixmap(QPixmap::fromImage(img)); } //垂直镜像 void ImageProcessor::ShowMirrorVertical() { if(img.isNull()) return; img = img.mirrored(false, true); //垂直镜像 showWidget->imageLabel->setPixmap(QPixmap::fromImage(img)); }
运行结果:
好吧,不知道又发生了什么,图片传不上来,那就省了吧,反正就是vertical就是上下颠倒,horizontal就是水平横移的效果!!!,
时间: 2024-11-02 07:35:24