日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

利用QtGraphicalEffects来使得自己的图像显示更加生动

發布時間:2023/10/11 综合教程 62 老码农
生活随笔 收集整理的這篇文章主要介紹了 利用QtGraphicalEffects来使得自己的图像显示更加生动 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

有興趣的開發人員能夠參閱連接http://doc.qt.io/qt-5/qtgraphicaleffects-qmlmodule.html來深度學習Qt對Graphics方面的處理。

在今天的這篇文章中。我們來使用OpacityMask做一個小小的樣例來拋磚引玉看看Qt對我們的圖像的處理。

詳細的樣例在Qt的官方站點上能夠看到。因為一些原因,在官方站點上下載的例程中的文件并不能被使用,須要做一些的處理才干夠。

以下,我們直接來把我們的樣例展示給大家:

import QtQuick 2.0
import Ubuntu.Components 1.1
import QtGraphicalEffects 1.0 /*!
\brief MainView with a Label and Button elements.
*/ MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView" // Note! applicationName needs to match the "name" field of the click manifest
applicationName: "mask.liu-xiao-guo" /*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
//automaticOrientation: true // Removes the old toolbar and enables new features of the new header.
useDeprecatedToolbar: false width: units.gu(60)
height: units.gu(85) Page {
title: i18n.tr("mask") Flickable {
anchors.fill: parent
contentHeight: mypics.childrenRect.height Item {
id: mypics
width: parent.width
height: units.gu(80) Image {
id: bug
height: parent.height/2
width: height
source: "images/bug.png"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
} Image {
id: bug1
height: parent.height/2
width: height
source: "images/bug.png"
anchors.top: bug.bottom
anchors.topMargin: units.gu(1)
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
} Rectangle {
id: mask
anchors.margins: 10
width: 65
height: 65
color: "black"
radius: width/2
clip: true
visible: false
} Image {
id: mask1
height: units.gu(40)
width: height
source: "images/bufferfly.png"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
} OpacityMask {
anchors.fill: bug
source: bug
maskSource: mask
} OpacityMask {
anchors.fill: bug1
source: bug
maskSource: mask1
}
}
}
}
}

在這里。我們使用了Image來展示圖片,可是。他們并非可見的(visible = false)。我們能夠通過一個掩膜mask,在mask上值為非透明的地方能夠顯示出圖像。

能夠通過OpacityMask來使得它們能夠顯示。

我們的mask圖片bufferfly.png例如以下:

bug.png的原圖為:

執行我們的例程,效果圖例如以下:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" width="200" height="300" alt="">  

源代碼在: https://github.com/liu-xiao-guo/mask

總結

以上是生活随笔為你收集整理的利用QtGraphicalEffects来使得自己的图像显示更加生动的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。