zoukankan      html  css  js  c++  java
  • Qt ------ 截图、获取鼠标指定的RGB值

    获取RGB值思路:截图,获取图片的(0,0)的RGB值

        int x = QCursor::pos().x();
        int y = QCursor::pos().y();
      // QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), x, y, 1, 1);
    
        QList<QScreen *> list_screen =  QGuiApplication::screens(); //可能电脑接了多个屏幕
    
        QPixmap pixmap = list_screen.at(0)->grabWindow(0,x,y,1,1);
        if (!pixmap.isNull()) //如果像素图不为NULL
        {
            QImage image = pixmap.toImage();//将像素图转换为QImage
            if (!image.isNull()) //如果image不为空
            {
                if (image.valid(0, 0)) //坐标位置有效
                {
                    QColor color = image.pixel(0, 0);
                    mousedPressed_R = color.red();
                    mousedPressed_G = color.green();
                    mousedPressed_B = color.blue();
                    QString text = QString("RGB: %1, %2, %3").arg(mousedPressed_R).arg(mousedPressed_G).arg(mousedPressed_B);
                    qDebug() << text;
                }
            }
        }
  • 相关阅读:
    加载中动画
    跑步动画
    关键帧动画
    animate.css
    怪异盒子
    弹性项目属性
    改变元素大小
    Linux 文件系统 --磁盘I/O
    Linux 文件系统
    Sample Test Strategy
  • 原文地址:https://www.cnblogs.com/god-of-death/p/8352568.html
Copyright © 2011-2022 走看看