Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhaikuscreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qhaikuscreen.h"
5
6#include "qhaikucursor.h"
7#include "qhaikuutils.h"
8
9#include <qpa/qwindowsysteminterface.h>
10
11#include <Bitmap.h>
12#include <Screen.h>
13#include <Window.h>
14
16 : m_screen(new BScreen(B_MAIN_SCREEN_ID))
17 , m_cursor(new QHaikuCursor)
18{
19 Q_ASSERT(m_screen->IsValid());
20}
21
23{
24 delete m_cursor;
25 m_cursor = nullptr;
26
27 delete m_screen;
28 m_screen = nullptr;
29}
30
31QPixmap QHaikuScreen::grabWindow(WId winId, int x, int y, int width, int height) const
32{
33 if (width == 0 || height == 0)
34 return QPixmap();
35
36 BScreen screen(nullptr);
37 BBitmap *bitmap = nullptr;
38 screen.GetBitmap(&bitmap);
39
40 const BRect frame = (winId ? ((BWindow*)winId)->Frame() : screen.Frame());
41
42 const int absoluteX = frame.left + x;
43 const int absoluteY = frame.top + y;
44
45 if (width < 0)
46 width = frame.Width() - x;
47 if (height < 0)
48 height = frame.Height() - y;
49
51
52 // get image of complete screen
53 QImage image((uchar*)bitmap->Bits(), screen.Frame().Width() + 1, screen.Frame().Height() + 1, bitmap->BytesPerRow(), format);
54
55 // extract the area of the requested window
56 QRect grabRect(absoluteX, absoluteY, width, height);
57 image = image.copy(grabRect);
58
59 delete bitmap;
60
62}
63
65{
66 const BRect frame = m_screen->Frame();
67 return QRect(frame.left, frame.top, frame.right - frame.left, frame.bottom - frame.top);
68}
69
71{
72 switch (format()) {
74 return 0;
75 break;
77 return 1;
78 break;
80 return 8;
81 break;
84 return 16;
85 break;
87 return 24;
88 break;
91 default:
92 return 32;
93 break;
94 }
95}
96
98{
99 return QHaikuUtils::colorSpaceToImageFormat(m_screen->ColorSpace());
100}
101
103{
104 return m_cursor;
105}
106
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
int depth() const override
Reimplement in subclass to return current depth of the screen.
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override
This function is called when Qt needs to be able to grab the content of a window.
\inmodule QtGui
Definition qimage.h:37
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGB888
Definition qimage.h:55
@ Format_RGB32
Definition qimage.h:46
@ Format_Invalid
Definition qimage.h:42
@ Format_MonoLSB
Definition qimage.h:44
@ Format_RGB555
Definition qimage.h:53
@ Format_Indexed8
Definition qimage.h:45
@ Format_RGB16
Definition qimage.h:49
@ Format_ARGB32
Definition qimage.h:47
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1437
The QPlatformCursor class provides information about pointer device events (movement,...
QScreen * screen() const
\inmodule QtCore\reentrant
Definition qrect.h:30
QImage::Format colorSpaceToImageFormat(color_space colorSpace)
Definition image.cpp:4
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLint GLsizei width
GLint GLsizei GLsizei GLenum format
GLint y
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
unsigned char uchar
Definition qtypes.h:32
QFrame frame
[0]