当前位置: 首页 > news >正文

使用QT画带有透明效果的图

分辨率:24X24

最大圆

 代码:

#include <QApplication>
#include <QImage>
#include <QPainter>

int main(int argc, char *argv[])
{
    QImage image(QSize(24,24),QImage::Format_ARGB32);
    image.fill(QColor(0,0,0,0));
    QPainter paint(&image);
    QRectF rect = image.rect();

    paint.setPen(QColor(255,255,255,0));
    paint.setBrush(QColor(255,255,255,255));

    paint.drawEllipse(rect);
    image.save("sun.png");

    return 0;
}

效果:

半径减一半

#include <QApplication>
#include <QImage>
#include <QPainter>
#include <QRect>
int main()
{
    QImage image(QSize(24,24),QImage::Format_ARGB32);
    image.fill(QColor(0,0,0,0));
    QPainter paint(&image);
    QRectF rect = image.rect();

    paint.setPen(QColor(255,255,255,0));
    paint.setBrush(QColor(255,255,255,255));

    // paint.drawEllipse(rect);
    paint.drawEllipse(rect.center().toPoint(),6,6);
    image.save("sun.png");

    return 0;
}

http://www.dtcms.com/a/94212.html

相关文章:

  • 魔法原子,以全栈自研撬动人形机器人通用化未来
  • 【免费分享】PSO-BP特征重要性分析matlab语言
  • BFS解决最短路径问题(使用BFS解决最短路径问题的黄金法则)
  • Python生成整数序列之 range()函数
  • 《C++11:bind绑定器与function包装器》
  • Kotlin when 表达式完全指南:从基础到高级的12种实战用法
  • Redis的深入了解
  • 页面类buttons权限的简单控制
  • MySQL学习日志--多表查询篇
  • NDK CMake工程中引入其他C++三方库
  • 视频格式转换:畅享多平台无缝视频体验
  • 31天Python入门——第16天:模块与库详解
  • StarRocks语句解析json字符串的方法
  • 还刷刷刷刷刷
  • 洛谷1044栈C语言
  • 2025Java面试TOP1000问:源码级解答+避坑指南+性能优化
  • [C++][STL]unordered_set类和unordered_map类
  • 【MySQL】从零开始:掌握MySQL数据库的核心概念(五)
  • columns实现瀑布流布局
  • ⑦(ACG-网络配置)
  • 06 单目标定-去畸变
  • React Native与原生Android数据传递
  • 【Unity】 鼠标拖动物体移动速度跟不上鼠标,会掉落
  • 学习《JS数据结构与算法》
  • 同步整流和异步整流区别及其各优点
  • vm虚拟机 Ubuntu ping失败情况解决方法
  • Python的迭代器(Iterator)介绍以及实现多次使用
  • SVTAV1热点函数-svt_ext_all_sad_calculation_8x8_16x16_avx2
  • pip 安装某个包之后,Jupyter Lab仍旧显示包冲突;例如:Numba needs NumPy 2.1 or less. Got NumPy 2.2.
  • 热血传奇2超高清重置UI素材