mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Update X11Grabber.cpp
Former-commit-id: 849f1a2b6217b76739f84f6c9fb5645cab584f98
This commit is contained in:
parent
9156742aaa
commit
2a1673d8c3
@ -55,11 +55,24 @@ Image<ColorRgb> & X11Grabber::grab()
|
|||||||
|
|
||||||
updateScreenDimensions();
|
updateScreenDimensions();
|
||||||
|
|
||||||
|
Xscreen = DefaultScreenOfDisplay(_x11Display);
|
||||||
|
|
||||||
const unsigned croppedWidth = _screenWidth - _cropLeft - _cropRight;
|
const unsigned croppedWidth = _screenWidth - _cropLeft - _cropRight;
|
||||||
const unsigned croppedHeight = _screenHeight - _cropTop - _cropBottom;
|
const unsigned croppedHeight = _screenHeight - _cropTop - _cropBottom;
|
||||||
|
|
||||||
|
xImage = XShmCreateImage(_x11Display, DefaultVisualOfScreen(Xscreen),
|
||||||
|
DefaultDepthOfScreen(Xscreen),
|
||||||
|
ZPixmap, NULL, &shminfo,
|
||||||
|
croppedWidth, croppedHeight);
|
||||||
|
|
||||||
|
shminfo.shmid = shmget(IPC_PRIVATE, xImage->bytes_per_line * xImage->height, IPC_CREAT|0777);
|
||||||
|
shminfo.shmaddr = xImage->data = (char*)shmat(shminfo.shmid,0,0);
|
||||||
|
shminfo.readOnly = False;
|
||||||
|
|
||||||
|
XShmAttach(_x11Display, &shminfo);
|
||||||
|
|
||||||
// Capture the current screen
|
// Capture the current screen
|
||||||
XImage * xImage = XGetImage(_x11Display, DefaultRootWindow(_x11Display), _cropLeft, _cropTop, croppedWidth, croppedHeight, AllPlanes, ZPixmap);
|
XShmGetImage(_x11Display, DefaultRootWindow(_x11Display), xImage, _cropLeft, _cropTop, 0x00FFFFFF);
|
||||||
if (xImage == nullptr)
|
if (xImage == nullptr)
|
||||||
{
|
{
|
||||||
std::cerr << "Grab failed" << std::endl;
|
std::cerr << "Grab failed" << std::endl;
|
||||||
@ -69,7 +82,10 @@ Image<ColorRgb> & X11Grabber::grab()
|
|||||||
_imageResampler.processImage(reinterpret_cast<const uint8_t *>(xImage->data), xImage->width, xImage->height, xImage->bytes_per_line, PIXELFORMAT_BGR32, _image);
|
_imageResampler.processImage(reinterpret_cast<const uint8_t *>(xImage->data), xImage->width, xImage->height, xImage->bytes_per_line, PIXELFORMAT_BGR32, _image);
|
||||||
|
|
||||||
// Cleanup allocated resources of the X11 grab
|
// Cleanup allocated resources of the X11 grab
|
||||||
|
XShmDetach(_x11Display, &shminfo);
|
||||||
XDestroyImage(xImage);
|
XDestroyImage(xImage);
|
||||||
|
shmdt (shminfo.shmaddr);
|
||||||
|
shmctl(shminfo.shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
return _image;
|
return _image;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user