mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-04-26 13:17:39 +08:00
update
This commit is contained in:
parent
06c9b4e382
commit
c0726d89f0
@ -42,28 +42,24 @@ ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedIt
|
|||||||
void ScreenshotBackground::paint(QPainter* painter)
|
void ScreenshotBackground::paint(QPainter* painter)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
QPixmap sourcePixmap;
|
_sourcePixmap = QPixmap(QSize(_desktopGeometry.width(),_desktopGeometry.height()));
|
||||||
QPainter p(&sourcePixmap);
|
QPainter p(&_sourcePixmap);
|
||||||
p.drawPixmap(_desktopGeometry,_desktopPixmap);
|
p.drawPixmap(_desktopGeometry,_desktopPixmap);
|
||||||
painter->drawPixmap(_desktopGeometry,sourcePixmap);
|
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
||||||
qDebug()<<start;
|
|
||||||
qDebug()<<end;
|
|
||||||
_grabResult = grabToImage();
|
_grabResult = grabToImage();
|
||||||
auto x = qMin(start.x(),end.x());
|
auto x = qMin(start.x(),end.x());
|
||||||
auto y = qMin(start.y(),end.y());
|
auto y = qMin(start.y(),end.y());
|
||||||
auto w = qAbs(end.x()-start.x());
|
auto w = qAbs(end.x()-start.x());
|
||||||
auto h = qAbs(end.y()-start.y());
|
auto h = qAbs(end.y()-start.y());
|
||||||
_captureRect = QRect(x,y,w,h);
|
_captureRect = QRect(x,y,w,h);
|
||||||
qDebug()<<_captureRect;
|
|
||||||
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &ScreenshotBackground::handleGrabResult);
|
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &ScreenshotBackground::handleGrabResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::handleGrabResult(){
|
void ScreenshotBackground::handleGrabResult(){
|
||||||
_grabResult.data()->image().copy(_captureRect).save("aaa.png");
|
_sourcePixmap.copy(_captureRect).save("aaa.png");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QRect _desktopGeometry;
|
QRect _desktopGeometry;
|
||||||
QPixmap _desktopPixmap;
|
QPixmap _desktopPixmap;
|
||||||
|
QPixmap _sourcePixmap;
|
||||||
qreal _devicePixelRatio;
|
qreal _devicePixelRatio;
|
||||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||||
QRect _captureRect;
|
QRect _captureRect;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user