资源简介
使用 Qt Quick 实现的图像处理实例,支持黑白、锐化、底片、柔化、灰度、浮雕等特效。展示 Qt 中 QML 与 C++ 混合编程技术、多线程、自定义事件等关键技术。

代码片段和文件信息
#include “imageProcessor.h“
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef void (*AlgorithmFunction)(QString sourceFile QString destFile);
class AlgorithmRunnable;
class ExcutedEvent : public QEvent
{
public:
ExcutedEvent(AlgorithmRunnable *r)
: QEvent(evType()) m_runnable(r)
{
}
AlgorithmRunnable *m_runnable;
static QEvent::Type evType()
{
if(s_evType == QEvent::None)
{
s_evType = (QEvent::Type)registerEventType();
}
return s_evType;
}
private:
static QEvent::Type s_evType;
};
QEvent::Type ExcutedEvent::s_evType = QEvent::None;
static void _gray(QString sourceFile QString destFile)
{
QImage image(sourceFile);
if(image.isNull())
{
qDebug() << “load “ << sourceFile << “ failed! “;
return;
}
qDebug() << “depth - “ << image.depth();
int width = image.width();
int height = image.height();
QRgb color;
int gray;
for(int i = 0; i < width; i++)
{
for(int j= 0; j < height; j++)
{
color = image.pixel(i j);
gray = qGray(color);
image.setPixel(i j qRgba(gray gray gray qAlpha(color)));
}
}
image.save(destFile);
}
static void _binarize(QString sourceFile QString destFile)
{
QImage image(sourceFile);
if(image.isNull())
{
qDebug() << “load “ << sourceFile << “ failed! “;
return;
}
int width = image.width();
int height = image.height();
QRgb color;
QRgb avg;
QRgb black = qRgb(0 0 0);
QRgb white = qRgb(255 255 255);
for(int i = 0; i < width; i++)
{
for(int j= 0; j < height; j++)
{
color = image.pixel(i j);
avg = (qRed(color) + qGreen(color) + qBlue(color))/3;
image.setPixel(i j avg >= 128 ? white : black);
}
}
image.save(destFile);
}
static void _negative(QString sourceFile QString destFile)
{
QImage image(sourceFile);
if(image.isNull())
{
qDebug() << “load “ << sourceFile << “ failed! “;
return;
}
int width = image.width();
int height = image.height();
QRgb color;
QRgb negative;
for(int i = 0; i < width; i++)
{
for(int j= 0; j < height; j++)
{
color = image.pixel(i j);
negative = qRgba(255 - qRed(color)
255 - qGreen(color)
255 - qBlue(color)
qAlpha(color));
image.setPixel(i j negative);
}
}
image.save(destFile);
}
static void _emboss(QString sourceFile QStri
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-07-15 00:07 imageProcessor\
目录 0 2014-06-04 23:06 imageProcessor\android\
文件 3471 2014-06-04 23:06 imageProcessor\android\AndroidManifest.xm
文件 11531 2014-07-13 16:36 imageProcessor\imageProcessor.cpp
文件 993 2014-07-13 16:21 imageProcessor\imageProcessor.h
文件 783 2014-06-04 23:08 imageProcessor\imageProcessor.pro
文件 13401 2014-07-15 00:07 imageProcessor\imageProcessor.pro.user
文件 3400 2014-06-04 10:24 imageProcessor\imageProcessor64.png
文件 4945 2014-06-04 10:24 imageProcessor\imageProcessor80.png
文件 706 2014-07-13 16:46 imageProcessor\main.cpp
目录 0 2014-06-04 10:24 imageProcessor\qml\
目录 0 2014-07-14 23:42 imageProcessor\qml\imageProcessor\
文件 5147 2014-07-14 23:42 imageProcessor\qml\imageProcessor\main.qml
目录 0 2014-06-04 23:05 imageProcessor\qtquick2applicationviewer\
文件 2797 2014-06-04 23:05 imageProcessor\qtquick2applicationviewer\qtquick2applicationviewer.cpp
文件 948 2014-06-04 10:24 imageProcessor\qtquick2applicationviewer\qtquick2applicationviewer.h
文件 7492 2014-06-04 10:24 imageProcessor\qtquick2applicationviewer\qtquick2applicationviewer.pri
- 上一篇:点扩散函数PSF
- 下一篇:ER随机图代码C语言
相关资源
- qTox (基于 peer-to-peer )
- 国际象棋的qt源代码
- QT上位机
- qt媒体播放器
- QT5开发及源代码
- qt完整项目
- C++ mqtt 用法
- qt进度条(RoundProgressBar)
- Qt的纽带风格界面实现(Office Ribbon风
- qt 实现画板
- QT Hisi demo
- 基础qt数据库读取和显示
- Qt画图工具源码(qgraphics draw)
- Qt查询SQLite数据库
- QtWebApp
- Qt 实现心电图
- Qt实现 屏幕截图
- qt cmd实现ping
- QT实现USB摄像头拍照
- qt texteditor(富文本编辑器)
- qt 串口助手源码
- qt登录富文本编辑器和文档打印设计
- 使用QWT库实现接收串口数据,并根据
- QT SQLite封装
- QML非常经典的代码
- QT半透明效果界面
- Qt5串口通信-windows
- 计算机远程唤醒和关机
- 使用wxWidgets进行跨平台程序开发
- QT 动态曲线
评论
共有 条评论