summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp')
-rw-r--r--Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
index a5eeafd..aae2ff1 100644
--- a/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
+++ b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
@@ -11,20 +11,17 @@
#include <QApplication>
#include <QDesktopWidget>
+#include <QPainter>
+#include <QColor>
+
#include <Swiften/ScreenSharing/Image.h>
-/*#include <QImage>
-#include <QLabel>*/
+#include <Swiften/Base/Log.h>
namespace Swift {
QtDesktopScreenGrabber::QtDesktopScreenGrabber()
{
- /*Image img = grab();
- QImage qImg(img.data.data(), img.width, img.height, QImage::Format_RGB888);
- QLabel *label = new QLabel;
- label->setPixmap(QPixmap::fromImage(qImg));
- label->show();*/
}
QtDesktopScreenGrabber::~QtDesktopScreenGrabber()
@@ -33,7 +30,35 @@ QtDesktopScreenGrabber::~QtDesktopScreenGrabber()
Image QtDesktopScreenGrabber::grab() const
{
- QImage qImg = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage().convertToFormat(QImage::Format_RGB888);
+ QImage qImg = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage();//.convertToFormat(QImage::Format_RGB888);
+// QImage qImg("/home/yb/Images/wallpaper-1681250.jpg");
+ qImg = qImg.scaled(qImg.width() * 0.7, qImg.height() * 0.7, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+// SWIFT_LOG(debug) << "Format RGB32: " << (qImg.format() == QImage::Format_RGB32) << std::endl;
+
+// QImage qImg(1920, 1080, QImage::Format_RGB32);
+// qImg.fill(QColor(qrand() % 255, qrand()%255, qrand()%255));
+// QPainter p(&qImg);
+// p.translate(qImg.width() / 2, qImg.height() / 2);
+// p.setBrush(Qt::black);
+// static int x = 0;
+// static int y = 0;
+// x = (x+50)%qImg.width();
+// y = (y+50)%qImg.height();
+// p.drawEllipse(x, y, 100, 100);
+
+// for (int i = 0; i < 40; ++i) {
+// p.setBrush(QColor(qrand() % 255, qrand()%255, qrand()%255));
+// p.drawEllipse(qrand()%qImg.width(), qrand()%qImg.height(), qrand()%(qImg.width()/4), qrand()%(qImg.height()/4));
+// }
+// p.end();
+
+ qImg = qImg.convertToFormat(QImage::Format_RGB888);
+
+// uchar* bits = qImg.bits();
+// for (int i = 0; i < qImg.byteCount(); ++i) {
+// bits[i] = qrand();
+// }
+
return Image(qImg.width(), qImg.height(), qImg.constBits());
}