当前位置: 首页>>代码示例>>C++>>正文


C++ QScreen::grabWindow方法代码示例

本文整理汇总了C++中QScreen::grabWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ QScreen::grabWindow方法的具体用法?C++ QScreen::grabWindow怎么用?C++ QScreen::grabWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QScreen的用法示例。


在下文中一共展示了QScreen::grabWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_getscreenimg_clicked

void MainWindow::on_getscreenimg_clicked()
{
    /*截屏*/
    QScreen *screen = QGuiApplication::primaryScreen();
    //ui->screenimg->hueLayerImage = screen->grabWindow(0);
    ui->screenimg->paint(screen->grabWindow(0));
    /*调整控件大小*/
    ui->screenimg->setMinimumWidth(screen->grabWindow(0).width());
    ui->screenimg->setMinimumHeight(screen->grabWindow(0).height());
    ui->scrollAreaWidgetContents->setMinimumWidth(screen->grabWindow(0).width());
    ui->scrollAreaWidgetContents->setMinimumHeight(screen->grabWindow(0).height());
}
开发者ID:egshuai,项目名称:egshuai,代码行数:12,代码来源:mainwindow.cpp

示例2: width

void
GLView::grabScreen( ){

	if( parameterVerhalten.zustand == ParameterVerhalten::AUS ) {

		return;
	}

//	if(	texture ) {

//		glDeleteTextures( 1,	&texture );
//	}

	QRect
	desktopRect(	QGuiApplication::primaryScreen( )->availableGeometry( ) );

	QPixmap
	pixmap_;

	QScreen
	*screen = QGuiApplication::primaryScreen( );

	switch( parameterVerhalten.zustand ) {

		case ParameterVerhalten::AUS : {

			return;
		}

		case ParameterVerhalten::HORIZONTAL : {

			pixmap_ = screen->grabWindow( QApplication::desktop( )->winId( ), screenOnLowerSide * width( ),	y( ), width( ), height( ) );

			break;
		}

		case ParameterVerhalten::VERTIKAL : {

			pixmap_ =	screen->grabWindow( QApplication::desktop( )->winId( ), x( ),  desktopRect.y( ) + screenOnLowerSide * height( ), width( ), height( ) );

			break;
		}
	}

	screenShotImage	= pixmap_.toImage( );

	GLView::convertToGLFormat(	screenShotImage );
}
开发者ID:samuelohterion,项目名称:SehenMitAndererAugen_ViewingWithOthersEyes,代码行数:48,代码来源:glview.cpp

示例3: grabColor

void ScreenSelector::grabColor()
{
    m_selectionRect = m_selectionRect.normalized();
    QDesktopWidget* desktop = QApplication::desktop();
    int screenNum = desktop->screenNumber(m_selectionRect.topLeft());
    QScreen* screen = QGuiApplication::screens()[screenNum];
    QPixmap screenGrab = screen->grabWindow(desktop->winId(),
        m_selectionRect.x(), m_selectionRect.y(), m_selectionRect.width(), m_selectionRect.height());
    QImage image = screenGrab.toImage();
    int numPixel = image.width() * image.height();
    int sumR = 0;
    int sumG = 0;
    int sumB = 0;

    for (int x = 0; x < image.width(); ++x) {
        for (int y = 0; y < image.height(); ++y) {
            QColor color = image.pixel(x, y);
            sumR += color.red();
            sumG += color.green();
            sumB += color.blue();
        }
    }

    QColor avgColor(sumR / numPixel, sumG / numPixel, sumB / numPixel);
    emit colorPicked(avgColor);
}
开发者ID:bmatherly,项目名称:shotcut,代码行数:26,代码来源:colorpickeritem.cpp

示例4: setThumbnail

void MainWindow::setThumbnail(int i) {
    QLabel *screenshotLabel;

    if (thumbnails[i] == NULL) {
        screenshotLabel = new QLabel;
        screenshotLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        screenshotLabel->setAlignment(Qt::AlignCenter);
        screenshotLabel->setMinimumSize(240, 160);

        layout->addWidget(screenshotLabel, i / 3, i % 3);
        thumbnails[i] = screenshotLabel;
    }
    else {
        screenshotLabel = thumbnails[i];
    }

    QScreen *srn = QApplication::screens().at(0);
    QPixmap workspacePixmap = srn->grabWindow(QApplication::desktop()->winId());

    screenshotLabel->setPixmap(
        workspacePixmap.scaled(
            screenshotLabel->size(),
            Qt::KeepAspectRatio,
            Qt::SmoothTransformation
        )
    );
}
开发者ID:infoforcefeed,项目名称:shitspace,代码行数:27,代码来源:mainwindow.cpp

示例5: updatePosition

void ColorPicker::updatePosition()
{
    QPoint pos = QCursor::pos();
    QScreen *screen = findScreenAt(pos);
    if (!screen) {
        qWarning() << "Could not find a screen containing" << pos;
        return;
    }
    QRect desktopRect = screen->geometry();

    QPoint newPos;
    if (pos.x() + GRAB_SIZE + width() < desktopRect.width()) {
        newPos.setX(pos.x() + GRAB_SIZE);
    } else {
        newPos.setX(pos.x() - GRAB_SIZE - width());
    }
    if (pos.y() + GRAB_SIZE + height() < desktopRect.height()) {
        newPos.setY(pos.y() + GRAB_SIZE);
    } else {
        newPos.setY(pos.y() - GRAB_SIZE - height());
    }

    move(newPos);

    WId wid = QApplication::desktop()->winId();
    mPixmap = screen->grabWindow(wid, pos.x() - GRAB_SIZE / 2, pos.y() - GRAB_SIZE / 2, GRAB_SIZE, GRAB_SIZE);
    update();
}
开发者ID:agateau,项目名称:colorpick,代码行数:28,代码来源:colorpicker.cpp

示例6: run

void BleWindowsCaptureSource::run()
{
    // TODO make could select screen
    // QGuiApplication::screens();
    while (!m_stop) {
        QElapsedTimer elapsedTimer;
        elapsedTimer.start();

        QScreen *screen = QGuiApplication::primaryScreen();

        if (screen) {
            QPixmap pixmap = screen->grabWindow(m_wid, m_x, m_y, m_width, m_height);
#if 1
            // TODO to draw cursor to image
            QRect desktopRect = QRect(QPoint(0, 0), screen->size());
            if (desktopRect.contains(QCursor::pos())) {
                drawCursor(&pixmap);
            }
#endif
            QImage image = pixmap.toImage();

            m_modifyMutex.lock();           // Start lock

            BleImage be;
            be.width = image.width();
            be.height = image.height();

            int imageSize = be.width * be.height * 3;
            be.data = new char[imageSize];

            IplImage *oriImage = cvCreateImageHeader(cvSize(image.width(), image.height()), IPL_DEPTH_8U, 4);
            cvSetData(oriImage, image.bits(), image.bytesPerLine());

            IplImage *dstImage = cvCreateImageHeader(cvSize(image.width(), image.height()), IPL_DEPTH_8U, 3);
            cvSetData(dstImage, be.data, be.width * 3);

            cvCvtColor(oriImage, dstImage, CV_BGRA2BGR);

            be.dataSize = imageSize;
            be.format = BleImage_Format_BGR24;

            m_image = be;

            cvReleaseImageHeader(&oriImage);
            cvReleaseImageHeader(&dstImage);

            m_modifyMutex.unlock();        // End unlock
        }

        int elapsedMs = elapsedTimer.elapsed();
        int needSleepMs = m_interval - elapsedMs;
        if (needSleepMs < 0) {
            needSleepMs = 0;
        }
        msleep(needSleepMs);
    }

    log_trace("BleWindowsCaptureSource exit normally.");
}
开发者ID:JaydenChou,项目名称:Bull-Live-Encoder,代码行数:59,代码来源:BleWindowsCaptureSource.cpp

示例7: getFullScreenPixmap

QPixmap WizScreenShotWidget::getFullScreenPixmap()
{
    initCWizScreenShotWidget();
    QPixmap result = QPixmap();
    QScreen *screen = QGuiApplication::primaryScreen();
    result = screen->grabWindow(0);

    return result;
}
开发者ID:JamesLinus,项目名称:WizQTClient,代码行数:9,代码来源:WizScreenShotWidget.cpp

示例8: grabScreen

QPixmap ScreenshotGrabber::grabScreen()
{
    QScreen* screen = QGuiApplication::primaryScreen();
    QRect rec = screen->virtualGeometry();

    // Multiply by devicePixelRatio to get actual desktop size
    return screen->grabWindow(QApplication::desktop()->winId(), rec.x() * pixRatio,
                              rec.y() * pixRatio, rec.width() * pixRatio, rec.height() * pixRatio);
}
开发者ID:initramfs,项目名称:qTox,代码行数:9,代码来源:screenshotgrabber.cpp

示例9: shoot

void Timer::shoot()
{
    QScreen *screen = QGuiApplication::primaryScreen();
    if (screen) {
        QPixmap pixmap;
        pixmap = screen->grabWindow(0);
        save(pixmap);
    }
}
开发者ID:tickmo,项目名称:desktop,代码行数:9,代码来源:timer.cpp

示例10: grabScreen

QPixmap ScreenshotGrabber::grabScreen()
{
    QScreen* screen = QGuiApplication::primaryScreen();
    QRect rec = screen->virtualGeometry();
    return screen->grabWindow(QApplication::desktop()->winId(),
                              rec.x(),
                              rec.y(),
                              rec.width(),
                              rec.height());
}
开发者ID:kingctan,项目名称:qTox,代码行数:10,代码来源:screenshotgrabber.cpp

示例11: getFullScreenPixmap

QPixmap getFullScreenPixmap()
{
    QRect rect = QApplication::desktop()->geometry();
    QScreen *screen = QGuiApplication::primaryScreen();

    //QPixmap result = screen->grabWindow(QApplication::desktop()->winId(), rect.left(), rect.top(), rect.width(), rect.height());
    QPixmap result = screen->grabWindow(QApplication::desktop()->winId(), rect.left(), rect.top(), 500, 500);

    return result;
}
开发者ID:shihuaxiang,项目名称:mystudio,代码行数:10,代码来源:mytranswidget.cpp

示例12: mouseReleaseEvent

void CDlgScreenShot::mouseReleaseEvent(QMouseEvent *e)
{
    LOG_MODEL_DEBUG("screen shot", "mouseReleaseEvent:e->pos:x:%d;y:%d;QCursor::pos:x:%d;y:%d",
                    e->pos().x(), e->pos().y(),
                    QCursor::pos().x(), QCursor::pos().y());
    if(!m_bGrabing)
    {
        QWidget::mouseReleaseEvent(e);
        return;
    }
    if(e->button() == Qt::LeftButton)
    {
        m_bGrabing = false;
        setCursor(Qt::ArrowCursor);
        WId id = qApp->desktop()->winId();
        QRect rect = QRect(m_x,m_y,m_width,m_height).normalized();
        LOG_MODEL_DEBUG("screen shot", "x:%d;y:%d;width:%d;height:%d;DlgWidth:%d;DlgHeight:%d",
                        rect.x(),
                        rect.y(),
                        rect.width(),
                        rect.height(),
                        this->width(),
                        this->height());
        QPixmap pix = QPixmap();
        QScreen *pScreen = QGuiApplication::primaryScreen();
        pix = pScreen->grabWindow(id, rect.x(), rect.y(), rect.width(), rect.height());

        int x = rect.x(), y = rect.y() + rect.height();
        m_Editor.toolBar.show(); //需要先显示,才能得到正确的大小  
        QRect rectToolBar = m_Editor.toolBar.frameGeometry();
        LOG_MODEL_DEBUG("screen shot", "x:%d;y:%d;width:%d;height:%d",
                        rectToolBar.x(),
                        rectToolBar.y(),
                        rectToolBar.width(),
                        rectToolBar.height());
        if(y + rectToolBar.height() >= this->height())
        {
            y = rect.y() - rectToolBar.height();
        }
        else if(x + rectToolBar.width() >= this->width())
        {
            x = this->width() - rectToolBar.width();
            LOG_MODEL_ERROR("screen shot", "x:%d;y:%d;width:%d;height:%d;toolx:%d",
                            rectToolBar.x(),
                            rectToolBar.y(),
                            rectToolBar.width(),
                            rectToolBar.height(),
                            x);
        }
        m_Editor.toolBar.move(x, y);
        m_Editor.resetByImg(pix);
        m_Editor.move(rect.topLeft());//移动到当前选择的rect的左上角  
        m_Editor.show();
    }
}
开发者ID:KangLin,项目名称:rabbitim,代码行数:55,代码来源:DlgScreenShot.cpp

示例13: sampleColor

QColor QgsColorButton::sampleColor( QPoint point ) const
{
  QScreen *screen = findScreenAt( point );
  if ( ! screen )
  {
    return QColor();
  }
  QPixmap snappedPixmap = screen->grabWindow( QApplication::desktop()->winId(), point.x(), point.y(), 1, 1 );
  QImage snappedImage = snappedPixmap.toImage();
  return snappedImage.pixel( 0, 0 );
}
开发者ID:dmarteau,项目名称:QGIS,代码行数:11,代码来源:qgscolorbutton.cpp

示例14: makeScreenshot

void PaintWidget::makeScreenshot()
{
    QScreen *screen = QGuiApplication::primaryScreen();
    if (screen)
    {
        screenshot_ = screen->grabWindow(0);

        //std::cout << "screenshot: " << screenshot_.width()<< "," << screenshot_.height() << std::endl;
        drawScreenhot_ = true;
        this->update();
    }
}
开发者ID:okard,项目名称:depot,代码行数:12,代码来源:PaintWidget.cpp

示例15: requestPixmap

QPixmap ScreenCaptureProvider::requestPixmap(const QString &/*id*/, QSize * /*size*/, const QSize& /*requestedSize*/)
{
	QScreen *screen = QGuiApplication::primaryScreen();
	if (screen)
	{
		QPixmap screenShotPixmap = screen->grabWindow(0);
		qDebug() << screen->geometry();
		setLastPixmap(screenShotPixmap);

		return screenShotPixmap;
	}

	return QPixmap();
}
开发者ID:gunoodaddy,项目名称:Lazybones3,代码行数:14,代码来源:screencaptureprovider.cpp


注:本文中的QScreen::grabWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。