MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / GetDisplay

Method GetDisplay

Service/DisplayXLib.cpp:173–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173QImage CDisplayXLib::GetDisplay(int x, int y, int width, int height)
174{
175 if(!m_pDisplay || 0 == m_RootWindow)
176 return QImage();
177
178 if(0 > width)
179 width = Width();
180 if(0 > height)
181 height = Height();
182 XImage *pImage = XGetImage(m_pDisplay, m_RootWindow, x, y, width, height,
183 AllPlanes, ZPixmap);
184 if(QImage::Format_Invalid == GetFormat())
185 m_Format = GetFormat(pImage);
186 if(QImage::Format_Invalid != GetFormat())
187 {
188 QImage img((uchar*)pImage->data,
189 pImage->width, pImage->height,
190 GetFormat(),
191 DestroyImage, pImage);
192
193 if(GetHasCursor())
194 {
195 QPoint pos, posHot;
196 QImage cursor = GetCursor(pos, posHot);
197 if(!cursor.isNull()
198 && pos.x() >= x && (pos.x() + cursor.width()) <= width
199 && pos.y() >= y && (pos.y() + cursor.height()) <= height)
200 {
201 QPainter painter(&img);
202 painter.drawImage(pos, cursor);
203 }
204 }
205
206 return img;
207 }
208 else
209 DestroyImage(pImage);
210
211 return QImage();
212}
213
214QImage CDisplayXLib::GetDisplay()
215{

Callers 1

GetDesktopMethod · 0.45

Calls 2

GetFormatFunction · 0.85
GetHasCursorFunction · 0.70

Tested by

no test coverage detected