Skip to content

Commit 7e54f37

Browse files
committed
Add QmlGrayImage
1 parent 8f5f6d7 commit 7e54f37

File tree

8 files changed

+83
-1
lines changed

8 files changed

+83
-1
lines changed

QmlGrayImage/1.png

40.5 KB
Loading

QmlGrayImage/QmlGrayImage.pro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#-------------------------------------------------
2+
#
3+
# Copyright (C) 2003-2103 CamelSoft Corporation
4+
#
5+
#-------------------------------------------------
6+
7+
QT += qml quick
8+
9+
CONFIG += c++11
10+
11+
SOURCES += main.cpp
12+
13+
RESOURCES += qml.qrc

QmlGrayImage/main.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*!
2+
*@file main.cpp
3+
*@brief 程序主文件
4+
*@version 1.0
5+
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6+
*@author zhengtianzuo
7+
*/
8+
#include <QGuiApplication>
9+
#include <QQmlApplicationEngine>
10+
11+
int main(int argc, char *argv[])
12+
{
13+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
14+
QGuiApplication app(argc, argv);
15+
16+
QQmlApplicationEngine engine;
17+
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
18+
19+
return app.exec();
20+
}

QmlGrayImage/main.qml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*!
2+
*@file main.qml
3+
*@brief 主文件
4+
*@version 1.0
5+
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
6+
*@author zhengtianzuo
7+
*/
8+
import QtQuick 2.7
9+
import QtQuick.Controls 2.0
10+
import QtGraphicalEffects 1.0
11+
12+
ApplicationWindow {
13+
visible: true
14+
width: 400
15+
height: 300
16+
title: qsTr("Qml图片转灰度")
17+
18+
Row{
19+
anchors.centerIn: parent
20+
21+
Image {
22+
id: source
23+
source: "qrc:/1.png"
24+
smooth: true
25+
}
26+
27+
Image {
28+
id: target
29+
source: "qrc:/1.png"
30+
smooth: true
31+
Desaturate {
32+
anchors.fill: parent
33+
source: parent
34+
desaturation: 1.0
35+
}
36+
}
37+
}
38+
}

QmlGrayImage/qml.qrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<RCC>
2+
<qresource prefix="/">
3+
<file>main.qml</file>
4+
<file>1.png</file>
5+
</qresource>
6+
</RCC>

QmlGrayImage/show.jpg

18.6 KB
Loading

QtQuickExamples.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ SUBDIRS += QmlToggleButton
2929
SUBDIRS += QmlCircularProgress
3030
SUBDIRS += QmlFontList
3131
SUBDIRS += QmlFlipImage
32-
32+
SUBDIRS += QmlGrayImage

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ QmlFlipImage: Qml翻转效果
127127

128128
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlFlipImage/show.gif?raw=true)
129129

130+
131+
QmlGrayImage: Qml图片转灰度
132+
133+
![](https://github.com/zhengtianzuo/QtQuickExamples/blob/master/QmlGrayImage/show.jpg?raw=true)
134+

0 commit comments

Comments
 (0)