mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fix output size of X11 image after deciamtion
Former-commit-id: c6120c7c4116f855405f65c21b0c0f5e1e443b6b
This commit is contained in:
parent
0fd25285a6
commit
bf7ddf5991
@ -706,6 +706,11 @@ void V4L2Grabber::process_image(const uint8_t * data)
|
||||
// create output structure
|
||||
int outputWidth = (width - _cropLeft - _cropRight + _horizontalPixelDecimation/2) / _horizontalPixelDecimation;
|
||||
int outputHeight = (height - _cropTop - _cropBottom + _verticalPixelDecimation/2) / _verticalPixelDecimation;
|
||||
|
||||
// TODO: should this be the following (like X11):
|
||||
//int outputWidth = (width - _cropLeft - _cropRight + _horizontalPixelDecimation/2 - 1) / _horizontalPixelDecimation + 1;
|
||||
//int outputHeight = (height - _cropTop - _cropBottom + _verticalPixelDecimation/2 - 1) / _verticalPixelDecimation + 1;
|
||||
|
||||
Image<ColorRgb> image(outputWidth, outputHeight);
|
||||
|
||||
for (int ySource = _cropTop + _verticalPixelDecimation/2, yDest = 0; ySource < height - _cropBottom; ySource += _verticalPixelDecimation, ++yDest)
|
||||
|
@ -64,8 +64,11 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
|
||||
// Copy the capture XImage to the local image (and apply required decimation)
|
||||
ColorRgb * outputPtr = _image.memptr();
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
for (int iY=(_pixelDecimation/2); iY<croppedHeight; iY+=_pixelDecimation)
|
||||
{
|
||||
width = 0;
|
||||
for (int iX=(_pixelDecimation/2); iX<croppedWidth; iX+=_pixelDecimation)
|
||||
{
|
||||
// Extract the pixel from the X11-image
|
||||
@ -78,8 +81,13 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
|
||||
// Move to the next output pixel
|
||||
++outputPtr;
|
||||
++width;
|
||||
}
|
||||
++height;
|
||||
}
|
||||
|
||||
std::cout << "decimated X11 message: " << width << " x " << height << std::endl;
|
||||
|
||||
// Cleanup allocated resources of the X11 grab
|
||||
XDestroyImage(xImage);
|
||||
|
||||
@ -107,8 +115,9 @@ int X11Grabber::updateScreenDimensions()
|
||||
std::cout << "[" << _screenWidth << "x" << _screenHeight <<"]" << std::endl;
|
||||
|
||||
// Update the size of the buffer used to transfer the screenshot
|
||||
int width = (_screenWidth - 2 * _cropWidth + _pixelDecimation/2) / _pixelDecimation;
|
||||
int height = (_screenHeight - 2 * _cropHeight + _pixelDecimation/2) / _pixelDecimation;
|
||||
int width = (_screenWidth - 2 * _cropWidth - _pixelDecimation/2 - 1) / _pixelDecimation + 1;
|
||||
int height = (_screenHeight - 2 * _cropHeight - _pixelDecimation/2 - 1) / _pixelDecimation + 1;
|
||||
|
||||
_image.resize(width, height);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user