Qt Quick<OpacityMask> 圆角图片、异形图片的合成
2016-07-17 16:25
686 查看
图片:
1.png:
up.png:
sanpan.png:
mask图片用来描述轮廓,里面的内容无所谓,需要的是他的透明不规则区域。
src图片建议使用矩形的~
三胖更帅了…
.
绘制圆形可以不用图片,这样内存开销会节省
src和mask可以是任何item的派生组件。
例子:src为矩形 mask为箭头形透明图
1.png:
up.png:
sanpan.png:
mask图片用来描述轮廓,里面的内容无所谓,需要的是他的透明不规则区域。
src图片建议使用矩形的~
import QtQuick 2.7 import QtCanvas3D 1.1 import QtQuick.Window 2.2 import QtQuick.Controls 1.4 import QtGraphicalEffects 1.0 Window { title: qsTr("c3d2") width: 1280 height: 768 visible: true Item { width: 300 height: 300 Image { id: bug source: "qrc:/sanpan.png" sourceSize: Qt.size(parent.width, parent.height) anchors.fill: parent smooth: true visible: false } //轮廓 Image { id: mask source: "qrc:/1.png" anchors.fill: parent sourceSize: Qt.size(parent.width, parent.height) smooth: true visible: false } OpacityMask { anchors.fill: bug source: bug maskSource: mask } } }
三胖更帅了…
//轮廓 Image { id: mask source: "qrc:/up.png" anchors.fill: parent sourceSize: Qt.size(parent.width, parent.height) smooth: true visible: false }
.
绘制圆形可以不用图片,这样内存开销会节省
Rectangle{ id:mask smooth: true visible: false anchors.fill: parent radius: height/2 }
src和mask可以是任何item的派生组件。
例子:src为矩形 mask为箭头形透明图
Item { width: 300 height: 300 Rectangle{ id:bug anchors.fill: parent smooth: true visible: false color: "red" } //轮廓 Image { id: mask source: "qrc:/up.png" anchors.fill: parent sourceSize: Qt.size(parent.width, parent.height) smooth: true visible: false } OpacityMask { anchors.fill: bug source: bug maskSource: mask } }
相关文章推荐
- iOS开发 UITextFild/TextView限制字数(含联想词汇)
- LeetCode 347. Top K Frequent Elements
- ueditor富文本的使用以及“未找到上传文件”时的解决办法
- Fabric defect inspection using prior knowledge guided least squares regression
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- uImage在内存中无法正常启动——UBoot-2010.06在TQ2440上的移植--机器码配对
- Java多线程 之 同步队列BlockingQueue与管道(十五)
- UESTC 1150 排名表(拓扑排序、很容易错)
- [poj 3080]Blue Jeans [kmp]
- UIImage加载图片的方式以及Images.xcassets对于加载方法的影响
- virtualbox 复制虚拟机提示uuid is exists
- android打开媒体库、照相机相关代码总结及常用UI处理代码,值得收藏
- java GUI事件
- 注册收件箱监听器时,经常会警告:Exported receiver does not require permission
- Vue.js:轻量高效的前端组件化方案
- Android Studio 构建项目一直卡在 gradle build running 解决方法