QT- QT-lximagerEidtor图片编辑器
QT- QT-lximagerEidtor图片编辑器
- 一、演示效果
- 二、关键程序
- 三、下载链接
功能如下:
1、缩放、旋转、翻转和调整图像大小
2、幻灯片
3、缩略图栏(左、上或下);不同的缩略图大小
4、Exif数据栏
5、内联图像重命名
6、自定义快捷方式
7、图像注释(箭头、矩形、圆形、数字)
8、最近的文件
9、上传图片(Imgur)
10、截屏
一、演示效果

二、关键程序
using namespace LxImage;static bool hasXFixes() {int event_base, error_base;return XFixesQueryExtension(QX11Info::display(), &event_base, &error_base);
}ScreenshotDialog::ScreenshotDialog(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f), hasXfixes_(hasXFixes()) {ui.setupUi(this);Application* app = static_cast<Application*>(qApp);app->addWindow();if(!hasXfixes_) {ui.includeCursor->hide();}
}ScreenshotDialog::~ScreenshotDialog() {Application* app = static_cast<Application*>(qApp);app->removeWindow();
}void ScreenshotDialog::done(int r) {if(r == QDialog::Accepted) {hide();QDialog::done(r);XSync(QX11Info::display(), 0); // is this useful?int delay = ui.delay->value();if(delay == 0) {// NOTE:// Well, we need to give X and the window manager some time to// really hide our own dialog from the screen.// Nobody knows how long it will take, and there is no reliable// way to ensure that. Let's wait for 400 ms here for it.delay = 400;}else {delay *= 1000;}// the dialog object will be deleted in doScreenshot().QTimer::singleShot(delay, this, SLOT(doScreenshot()));}else {deleteLater();}
}QRect ScreenshotDialog::windowFrame(WId wid) {QRect result;XWindowAttributes wa;if(XGetWindowAttributes(QX11Info::display(), wid, &wa)) {Window child;int x, y;// translate to root coordinateXTranslateCoordinates(QX11Info::display(), wid, wa.root, 0, 0, &x, &y, &child);//qDebug("%d, %d, %d, %d", x, y, wa.width, wa.height);result.setRect(x, y, wa.width, wa.height);// get the frame widths added by the window managerAtom atom = XInternAtom(QX11Info::display(), "_NET_FRAME_EXTENTS", false);unsigned long type, resultLen, rest;int format;unsigned char* data = nullptr;if(XGetWindowProperty(QX11Info::display(), wid, atom, 0, G_MAXLONG, false,XA_CARDINAL, &type, &format, &resultLen, &rest, &data) == Success) {}if(data) { // left, right, top, bottomlong* offsets = reinterpret_cast<long*>(data);result.setLeft(result.left() - offsets[0]);result.setRight(result.right() + offsets[1]);result.setTop(result.top() - offsets[2]);result.setBottom(result.bottom() + offsets[3]);XFree(data);}}return result;
}WId ScreenshotDialog::activeWindowId() {WId root = WId(QX11Info::appRootWindow());Atom atom = XInternAtom(QX11Info::display(), "_NET_ACTIVE_WINDOW", false);unsigned long type, resultLen, rest;int format;WId result = 0;unsigned char* data = nullptr;if(XGetWindowProperty(QX11Info::display(), root, atom, 0, 1, false,XA_WINDOW, &type, &format, &resultLen, &rest, &data) == Success) {result = *reinterpret_cast<long*>(data);XFree(data);}return result;
}QImage ScreenshotDialog::takeScreenshot(const WId& wid, const QRect& rect, bool takeCursor) {QImage image;QScreen *screen = QGuiApplication::primaryScreen();if(screen) {QPixmap pixmap = screen->grabWindow(wid, rect.x(), rect.y(), rect.width(), rect.height());image = pixmap.toImage();//call to hasXFixes() maybe executed here from cmd line with no gui mode (some day though, currently ignore cursor)if(takeCursor && hasXFixes()) {// capture the cursor if neededXFixesCursorImage* cursor = XFixesGetCursorImage(QX11Info::display());if(cursor) {if(cursor->pixels) { // pixles should be an ARGB arrayQImage cursorImage;if(sizeof(long) == 4) {// FIXME: will we encounter byte-order problems here?cursorImage = QImage((uchar*)cursor->pixels, cursor->width, cursor->height, QImage::Format_ARGB32);}else { // XFixes returns long integers which is not 32 bit on 64 bit systems.long len = cursor->width * cursor->height;quint32* buf = new quint32[len];for(long i = 0; i < len; ++i) {buf[i] = (quint32)cursor->pixels[i];}cursorImage = QImage((uchar*)buf, cursor->width, cursor->height, QImage::Format_ARGB32, [](void* b) {delete[](quint32*)b;}, buf);}// paint the cursor on the current imageQPainter painter(&image);painter.drawImage(cursor->x - cursor->xhot, cursor->y - cursor->yhot, cursorImage);}XFree(cursor);}}}return image;
}void ScreenshotDialog::doScreenshot() {WId wid = 0;QRect rect{0, 0, -1, -1};wid = QApplication::desktop()->winId(); // get desktop windowif(ui.currentWindow->isChecked()) {WId activeWid = activeWindowId();if(activeWid) {if(ui.includeFrame->isChecked()) {rect = windowFrame(activeWid);}else {wid = activeWid;}}}//using stored hasXfixes_ so avoid extra call to function laterQImage image{takeScreenshot(wid, rect, hasXfixes_ && ui.includeCursor->isChecked())};if(ui.screenArea->isChecked() && !image.isNull()) {ScreenshotSelectArea selectArea(image);if(QDialog::Accepted == selectArea.exec()) {image = image.copy(selectArea.selectedArea());}}Application* app = static_cast<Application*>(qApp);MainWindow* window = app->createWindow();window->resize(app->settings().windowWidth(), app->settings().windowHeight());if(!image.isNull()) {window->pasteImage(image);}window->show();deleteLater(); // destroy ourself
}static QString buildNumericFnPart() {//we may have many copies running with no gui, for example user presses hot keys fast//so they must have different file names to save, lets do it time + pidconst auto now = QDateTime::currentDateTime().toMSecsSinceEpoch();const auto pid = getpid();return QStringLiteral("%1_%2").arg(now).arg(pid);
}static QString getWindowName(WId wid) {QString result;if(wid) {static const char* atoms[] = {"WM_NAME","_NET_WM_NAME","STRING","UTF8_STRING",};const auto display = QX11Info::display();Atom a = None, type;for(const auto& c : atoms) {if(None != (a = XInternAtom(display, c, true))) {int form;unsigned long remain, len;unsigned char *list;errno = 0;if(XGetWindowProperty(display, wid, a, 0, 1024, False, XA_STRING,&type, &form, &len, &remain, &list) == Success) {if(list && *list) {std::string dump((const char*)list);std::stringstream ss;for(const auto& sym : dump) {if(std::isalnum(sym)) {ss.put(sym);}}result = QString::fromStdString(ss.str());break;}}}}}return (result.isEmpty()) ? QStringLiteral("UNKNOWN") : result;
}void ScreenshotDialog::cmdTopShotToDir(QString path) {WId activeWid = activeWindowId();const QRect rect = (activeWid) ? windowFrame(activeWid) : QRect{0, 0, -1, -1};QImage img{takeScreenshot(QApplication::desktop()->winId(), rect, false)};QDir d;d.mkpath(path);QFileInfo fi(path);if(!fi.exists() || !fi.isDir() || !fi.isWritable()) {path = QDir::homePath();}const QString filename = QStringLiteral("%1/%2_%3").arg(path).arg(getWindowName(activeWid)).arg(buildNumericFnPart());const auto static png = QStringLiteral(".png");QString finalName = filename % png;//most unlikelly this will happen ... but user might change system clock or so and we dont want to overwrite filefor(int counter = 0; QFile::exists(finalName) && counter < 5000; ++counter) {finalName = QStringLiteral("%1_%2%3").arg(filename).arg(counter).arg(png);}//std::cout << finalName.toStdString() << std::endl;img.save(finalName);
}
三、下载链接
https://download.csdn.net/download/u013083044/88628914
相关文章:
QT- QT-lximagerEidtor图片编辑器
QT- QT-lximagerEidtor图片编辑器 一、演示效果二、关键程序三、下载链接 功能如下: 1、缩放、旋转、翻转和调整图像大小 2、幻灯片 3、缩略图栏(左、上或下);不同的缩略图大小 4、Exif数据栏 5、内联图像重命名 6、自定义快捷方式…...
PyQt 如何通过连续点击托盘图标显示隐藏主窗口并且在主窗口隐藏时调整界面到托盘图标附近
不废话直接看代码 # -*- codingutf-8 -*- # # author: Ruben # mail: 773849069qq.com # time: 2023/12/8 # u""" 一个托盘图标的小部件 """ from Qt import QtWidgets, QtGui, QtCore# --*--*--*--*--*--*--*--*--*--…...
什么是纯净IP?如何判断IP地址的纯净度?有哪些干净IP推荐?
您是否想知道什么使代理“干净”或如何确保您的代理不会将您列入网站的黑名单?对于通过代理访问网络的人来说,干净的代理是无缝在线体验的重要组成部分。在这篇文章中,我们将深入研究干净代理的世界,并探讨决定其质量的因素。 一、…...
MySQL和Minio数据备份
文章目录 一、MySQL数据备份1. MySQL客户端2. 数据增量备份3. 数据增量还原4. 数据全量备份5. 数据全量还原 二、Minio数据备份1. Minio客户端2. 数据备份3. 数据还原 三、其他参考1. 设置定时备份2. 数据拷贝到其他服务器3. MySQL其他语句 一、MySQL数据备份 Linux环境&#…...
在Go中过滤范型集合:性能回顾
在一个真实的 Golang 场景中使用泛型,同时寻找与 Stream filter(Predicate<? super T> predicate)和 Python list comprehension 等同的函数。我没有依赖现有的包,而是选择自己写一个过滤函数,以达到学习的目的 func filterStrings(c…...
MATLAB 最小二乘直线拟合方法二 (36)
MATLAB 最小二乘直线拟合方法二 (36) 一、算法介绍二、算法实现1.代码2.结果一、算法介绍 这里介绍另一种拟合直线点云的方法,更为简单方便,结果与前者一致,主要内容直接复制代码使用即可,原理简单看代码即可,下面是具体的实现和拟合结果展示 二、算法实现 1.代码 代…...
Python 实现:OCR在图片中提取文字(基于Gradio实现)
Paddle OCR PaddleOCR 基于深度学习技术实现的,使用十分简单。 先看效果 可以看出来识别效果还是不错的,里面的“湿”字识别成了繁体字。如果不是连体字,就不会出现这个问题。 1.测试环境 操作系统:Win10 Python:3…...
idea插件开发报错: ZipException opening “slf4j.jar“: zip END header not found
错误信息 E:\idea-workspace\#idea-plugin\JSON2Object\src\main\java\com\hgy\plugin\json2object\GenerateAction.java:1: 错误: 无法访问com.hgy.plugin.json2object package com.hgy.plugin.json2object; ^ZipException opening "slf4j.jar": zip END header no…...
【Linux】多线程编程
目录 1. 线程基础知识 2. 线程创建 3. 线程ID(TID) 4. 线程终止 5. 线程取消 6. 线程等待 7. 线程分离 8. 线程互斥 8.1 初始化互斥量 8.2 销毁互斥量 8.3 互斥量加锁和解锁 9. 可重入和线程安全 10. 线程同步之条件变量 10.1 初始化条件变…...
【Mysql】InnoDB的表空间(九)
概述 表空间是一个在 InnoDB 中比较抽象的概念,对于系统表空间来说,对应着文件系统中一个或多个实际文件;而对于每个独立表空间来说,对应着文件系统中一个名为表名.ibd 的实际文件。可以把表空间想象成由很多个页组成的池子&…...
【09】ES6:Set 和 Map 数据结构
一、Set 1、基本语法 定义 Set 是一系列无序、没有重复值的数据集合。数组是一系列有序(下标索引)的数据集合。 Set 本身是一个构造函数,用来生成 Set 数据结构。 const s new Set() [2, 3, 5, 4, 5, 2, 2].forEach(x > s.add(x))fo…...
Java通过documents4j和libreoffice把word转为pdf
文章目录 word转pdf的相关第三方jar说明Linux系统安装LibreOffice在线安装离线安装word转pdf验证 Java工具类代码 word转pdf的相关第三方jar说明 docx4j 免费开源、稍微复杂点的word,样式完全乱了,且xalan升级为2.7.3后会报错。poi 免费开源、官方文档少…...
物联网时代的访问控制研究综述
A survey on Access Control in the Age of Internet of Things 文章目录 A B S T R A C T引言A. Comparison Between This Paper and Existing SurveysB. Contributions II.ACCESS CONTROL BACKGROUNDIII. ACCESS CONTROL CHALLENGES IN IOT SEARCHA. Characteristics of IoT …...
【产品经理】需求池和版本树
在这个人人都是产品经理的时代,每位入行的产品人进阶速度与到达高度各有不同。本文作者结合自身三年产品行业的经历,根据案例拆解产品行业的极简研发过程、需求池、版本树、产品自我优化等相关具体方法论。 一、产品研发的极简过程 1. 产品概述 产品就…...
Qt图像处理-OpenCv中Mat与QImage互转
Qt图像处理时需要OpenCv中Mat与QImage互转,具体代码如下 创建EditPhoto,头文件,使用前需要配置好opencv #include <QObject> #include <QImage> #include <QDebug>#include<opencv2/core/core.hpp> #include<opencv2/highgui/highgui.hpp> …...
构建外卖小程序:技术代码实践
在这个数字化的时代,外卖小程序已经成为餐饮业的一项重要工具。在本文中,我们将通过一些简单而实用的技术代码,向您展示如何构建一个基本的外卖小程序。我们将使用微信小程序平台作为例子,但这些原理同样适用于其他小程序平台。 …...
IDEA中显示方法、类注释信息
目录 一、IDEA测试版本及环境二、操作步骤2.1 鼠标悬停在某一个方法上,从而显示方法的注释信息2.2 调用方法时同步显示方法注释信息2.3 在new一个对象时,这个对象有很多重载的构造方法,想要重载的构造函数都显示出来 一、IDEA测试版本及环境 …...
《数据结构、算法与应用C++语言描述》- 堆排序 - 借助priority_queue的C++实现
堆排序 完整可编译运行代码见:Github::Data-Structures-Algorithms-and-Applications/_27HeapSort 定义 借助堆进行排序。先用n个待排序的元素初始化一个小根堆,然后从堆中逐个提取(即删除元素)元素。初始化的时间复杂度为O(n),大根堆中每…...
10.CSS浮动
CSS浮动 1.介绍 在最初,浮动是用来实现文字环绕图片效果的,现在浮动是主流的页面布局方式之一 2.作用 让元素脱离标准流,同一级的浮动的元素可以并排在一排显示 3.元素浮动后的特点 脱离文档流不管浮动前是什么元素,浮动后&…...
Angular 2 学习笔记
Angular 2 应用主要由以下 几个部分组成: 1、模块 (Modules): 2、组件 (Components): 3、模板 (Templates): 4、元数据 (Metadata): 5、数据绑定 (Data Binding) 6、指令 (Directives) 7、服务 (Servic…...
IDEA运行Tomcat出现乱码问题解决汇总
最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…...
树莓派超全系列教程文档--(62)使用rpicam-app通过网络流式传输视频
使用rpicam-app通过网络流式传输视频 使用 rpicam-app 通过网络流式传输视频UDPTCPRTSPlibavGStreamerRTPlibcamerasrc GStreamer 元素 文章来源: http://raspberry.dns8844.cn/documentation 原文网址 使用 rpicam-app 通过网络流式传输视频 本节介绍来自 rpica…...
K8S认证|CKS题库+答案| 11. AppArmor
目录 11. AppArmor 免费获取并激活 CKA_v1.31_模拟系统 题目 开始操作: 1)、切换集群 2)、切换节点 3)、切换到 apparmor 的目录 4)、执行 apparmor 策略模块 5)、修改 pod 文件 6)、…...
Debian系统简介
目录 Debian系统介绍 Debian版本介绍 Debian软件源介绍 软件包管理工具dpkg dpkg核心指令详解 安装软件包 卸载软件包 查询软件包状态 验证软件包完整性 手动处理依赖关系 dpkg vs apt Debian系统介绍 Debian 和 Ubuntu 都是基于 Debian内核 的 Linux 发行版ÿ…...
基于Uniapp开发HarmonyOS 5.0旅游应用技术实践
一、技术选型背景 1.跨平台优势 Uniapp采用Vue.js框架,支持"一次开发,多端部署",可同步生成HarmonyOS、iOS、Android等多平台应用。 2.鸿蒙特性融合 HarmonyOS 5.0的分布式能力与原子化服务,为旅游应用带来…...
linux arm系统烧录
1、打开瑞芯微程序 2、按住linux arm 的 recover按键 插入电源 3、当瑞芯微检测到有设备 4、松开recover按键 5、选择升级固件 6、点击固件选择本地刷机的linux arm 镜像 7、点击升级 (忘了有没有这步了 估计有) 刷机程序 和 镜像 就不提供了。要刷的时…...
python爬虫:Newspaper3k 的详细使用(好用的新闻网站文章抓取和解析的Python库)
更多内容请见: 爬虫和逆向教程-专栏介绍和目录 文章目录 一、Newspaper3k 概述1.1 Newspaper3k 介绍1.2 主要功能1.3 典型应用场景1.4 安装二、基本用法2.2 提取单篇文章的内容2.2 处理多篇文档三、高级选项3.1 自定义配置3.2 分析文章情感四、实战案例4.1 构建新闻摘要聚合器…...
【AI学习】三、AI算法中的向量
在人工智能(AI)算法中,向量(Vector)是一种将现实世界中的数据(如图像、文本、音频等)转化为计算机可处理的数值型特征表示的工具。它是连接人类认知(如语义、视觉特征)与…...
企业如何增强终端安全?
在数字化转型加速的今天,企业的业务运行越来越依赖于终端设备。从员工的笔记本电脑、智能手机,到工厂里的物联网设备、智能传感器,这些终端构成了企业与外部世界连接的 “神经末梢”。然而,随着远程办公的常态化和设备接入的爆炸式…...
以光量子为例,详解量子获取方式
光量子技术获取量子比特可在室温下进行。该方式有望通过与名为硅光子学(silicon photonics)的光波导(optical waveguide)芯片制造技术和光纤等光通信技术相结合来实现量子计算机。量子力学中,光既是波又是粒子。光子本…...
