Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
15
QHaikuScreen::QHaikuScreen()
16
: m_screen(
new
BScreen(B_MAIN_SCREEN_ID))
17
, m_cursor(
new
QHaikuCursor)
18
{
19
Q_ASSERT(m_screen->IsValid());
20
}
21
22
QHaikuScreen::~QHaikuScreen()
23
{
24
delete
m_cursor;
25
m_cursor =
nullptr
;
26
27
delete
m_screen;
28
m_screen =
nullptr
;
29
}
30
31
QPixmap 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
50
const
QImage::Format format = QHaikuUtils::colorSpaceToImageFormat(bitmap->ColorSpace());
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
61
return
QPixmap::fromImage(image);
62
}
63
64
QRect QHaikuScreen::geometry()
const
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
70
int
QHaikuScreen::depth()
const
71
{
72
switch
(format()) {
73
case
QImage::Format_Invalid:
74
return
0;
75
break
;
76
case
QImage::Format_MonoLSB:
77
return
1;
78
break
;
79
case
QImage::Format_Indexed8:
80
return
8;
81
break
;
82
case
QImage::Format_RGB16:
83
case
QImage::Format_RGB555:
84
return
16;
85
break
;
86
case
QImage::Format_RGB888:
87
return
24;
88
break
;
89
case
QImage::Format_RGB32:
90
case
QImage::Format_ARGB32:
91
default
:
92
return
32;
93
break
;
94
}
95
}
96
97
QImage::Format QHaikuScreen::format()
const
98
{
99
return
QHaikuUtils::colorSpaceToImageFormat(m_screen->ColorSpace());
100
}
101
102
QPlatformCursor *QHaikuScreen::cursor()
const
103
{
104
return
m_cursor;
105
}
106
107
QT_END_NAMESPACE
qtbase
src
plugins
platforms
haiku
qhaikuscreen.cpp
Generated on
for Qt by
1.18.0