本文整理汇总了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());
}
示例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 );
}
示例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);
}
示例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
)
);
}
示例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();
}
示例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.");
}
示例7: getFullScreenPixmap
QPixmap WizScreenShotWidget::getFullScreenPixmap()
{
initCWizScreenShotWidget();
QPixmap result = QPixmap();
QScreen *screen = QGuiApplication::primaryScreen();
result = screen->grabWindow(0);
return result;
}
示例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);
}
示例9: shoot
void Timer::shoot()
{
QScreen *screen = QGuiApplication::primaryScreen();
if (screen) {
QPixmap pixmap;
pixmap = screen->grabWindow(0);
save(pixmap);
}
}
示例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());
}
示例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;
}
示例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();
}
}
示例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 );
}
示例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();
}
}
示例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();
}