mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Remove extra pixel consistently
This commit is contained in:
@@ -15,9 +15,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Image(unsigned width, unsigned height) :
|
||||
Image(int width, int height) :
|
||||
Image(width, height, Pixel_T())
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,7 +27,7 @@ public:
|
||||
/// @param height The height of the image
|
||||
/// @param background The color of the image
|
||||
///
|
||||
Image(unsigned width, unsigned height, const Pixel_T background) :
|
||||
Image(int width, int height, const Pixel_T background) :
|
||||
_d_ptr(new ImageData<Pixel_T>(width, height, background))
|
||||
{
|
||||
}
|
||||
@@ -78,7 +77,7 @@ public:
|
||||
///
|
||||
/// @return The width of the image
|
||||
///
|
||||
inline unsigned width() const
|
||||
inline int width() const
|
||||
{
|
||||
return _d_ptr->width();
|
||||
}
|
||||
@@ -88,7 +87,7 @@ public:
|
||||
///
|
||||
/// @return The height of the image
|
||||
///
|
||||
inline unsigned height() const
|
||||
inline int height() const
|
||||
{
|
||||
return _d_ptr->height();
|
||||
}
|
||||
@@ -111,7 +110,7 @@ public:
|
||||
///
|
||||
/// @return const reference to specified pixel
|
||||
///
|
||||
uint8_t blue(unsigned pixel) const
|
||||
uint8_t blue(int pixel) const
|
||||
{
|
||||
return _d_ptr->blue(pixel);
|
||||
}
|
||||
@@ -121,7 +120,7 @@ public:
|
||||
///
|
||||
/// @param x The x index
|
||||
/// @param y The y index
|
||||
const Pixel_T& operator()(unsigned x, unsigned y) const
|
||||
const Pixel_T& operator()(int x, int y) const
|
||||
{
|
||||
return _d_ptr->operator()(x, y);
|
||||
}
|
||||
@@ -129,7 +128,7 @@ public:
|
||||
///
|
||||
/// @return reference to specified pixel
|
||||
///
|
||||
Pixel_T& operator()(unsigned x, unsigned y)
|
||||
Pixel_T& operator()(int x, int y)
|
||||
{
|
||||
return _d_ptr->operator()(x, y);
|
||||
}
|
||||
@@ -137,7 +136,7 @@ public:
|
||||
/// Resize the image
|
||||
/// @param width The width of the image
|
||||
/// @param height The height of the image
|
||||
void resize(unsigned width, unsigned height)
|
||||
void resize(int width, int height)
|
||||
{
|
||||
_d_ptr->resize(width, height);
|
||||
}
|
||||
@@ -198,12 +197,11 @@ private:
|
||||
///
|
||||
/// @return The index into the underlying data-vector
|
||||
///
|
||||
inline unsigned toIndex(unsigned x, unsigned y) const
|
||||
inline int toIndex(int x, int y) const
|
||||
{
|
||||
return _d_ptr->toIndex(x, y);
|
||||
}
|
||||
|
||||
private:
|
||||
QSharedDataPointer<ImageData<Pixel_T>> _d_ptr;
|
||||
};
|
||||
|
||||
|
@@ -21,10 +21,10 @@ class ImageData : public QSharedData
|
||||
public:
|
||||
typedef Pixel_T pixel_type;
|
||||
|
||||
ImageData(unsigned width, unsigned height, const Pixel_T background) :
|
||||
ImageData(int width, int height, const Pixel_T background) :
|
||||
_width(width),
|
||||
_height(height),
|
||||
_pixels(new Pixel_T[width * height + 1])
|
||||
_pixels(new Pixel_T[static_cast<ssize_t>(width * height)])
|
||||
{
|
||||
std::fill(_pixels, _pixels + width * height, background);
|
||||
}
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
QSharedData(other),
|
||||
_width(other._width),
|
||||
_height(other._height),
|
||||
_pixels(new Pixel_T[other._width * other._height + 1])
|
||||
_pixels(new Pixel_T[other._width * other._height])
|
||||
{
|
||||
memcpy(_pixels, other._pixels, static_cast<ulong>(other._width) * static_cast<ulong>(other._height) * sizeof(Pixel_T));
|
||||
memcpy(_pixels, other._pixels, other._width * other._height * sizeof(Pixel_T));
|
||||
}
|
||||
|
||||
ImageData& operator=(ImageData rhs)
|
||||
@@ -71,42 +71,42 @@ public:
|
||||
delete[] _pixels;
|
||||
}
|
||||
|
||||
inline unsigned width() const
|
||||
inline int width() const
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
inline unsigned height() const
|
||||
inline int height() const
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
uint8_t red(unsigned pixel) const
|
||||
uint8_t red(int pixel) const
|
||||
{
|
||||
return (_pixels + pixel)->red;
|
||||
}
|
||||
|
||||
uint8_t green(unsigned pixel) const
|
||||
uint8_t green(int pixel) const
|
||||
{
|
||||
return (_pixels + pixel)->green;
|
||||
}
|
||||
|
||||
uint8_t blue(unsigned pixel) const
|
||||
uint8_t blue(int pixel) const
|
||||
{
|
||||
return (_pixels + pixel)->blue;
|
||||
}
|
||||
|
||||
const Pixel_T& operator()(unsigned x, unsigned y) const
|
||||
const Pixel_T& operator()(int x, int y) const
|
||||
{
|
||||
return _pixels[toIndex(x,y)];
|
||||
}
|
||||
|
||||
Pixel_T& operator()(unsigned x, unsigned y)
|
||||
Pixel_T& operator()(int x, int y)
|
||||
{
|
||||
return _pixels[toIndex(x,y)];
|
||||
}
|
||||
|
||||
void resize(unsigned width, unsigned height)
|
||||
void resize(int width, int height)
|
||||
{
|
||||
if (width == _width && height == _height)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
|
||||
// Allocate a new buffer without initializing the content
|
||||
Pixel_T* newPixels = new Pixel_T[static_cast<size_t>(width) * static_cast<size_t>(height)];
|
||||
Pixel_T* newPixels = new Pixel_T[static_cast<ssize_t>(width * height)];
|
||||
|
||||
// Release the old buffer without copying data
|
||||
delete[] _pixels;
|
||||
@@ -143,9 +143,9 @@ public:
|
||||
image.resize(_width, _height);
|
||||
}
|
||||
|
||||
const unsigned imageSize = _width * _height;
|
||||
const int imageSize = _width * _height;
|
||||
|
||||
for (unsigned idx = 0; idx < imageSize; idx++)
|
||||
for (int idx = 0; idx < imageSize; idx++)
|
||||
{
|
||||
const Pixel_T & color = _pixels[idx];
|
||||
image.memptr()[idx] = ColorRgb{color.red, color.green, color.blue};
|
||||
@@ -154,40 +154,29 @@ public:
|
||||
|
||||
ssize_t size() const
|
||||
{
|
||||
return static_cast<ssize_t>(_width) * static_cast<ssize_t>(_height) * sizeof(Pixel_T);
|
||||
return static_cast<ssize_t>(_width * _height) * sizeof(Pixel_T);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
if (_width != 1 || _height != 1)
|
||||
{
|
||||
_width = 1;
|
||||
_height = 1;
|
||||
|
||||
// Allocate a new buffer without initializing the content
|
||||
Pixel_T* newPixels = new Pixel_T[static_cast<size_t>(_width) * static_cast<size_t>(_height)];
|
||||
|
||||
// Release the old buffer without copying data
|
||||
delete[] _pixels;
|
||||
|
||||
// Update the pointer to the new buffer
|
||||
_pixels = newPixels;
|
||||
resize(1,1);
|
||||
}
|
||||
|
||||
// Set the single pixel to the default background
|
||||
_pixels[0] = Pixel_T();
|
||||
}
|
||||
|
||||
private:
|
||||
inline unsigned toIndex(unsigned x, unsigned y) const
|
||||
inline int toIndex(int x, int y) const
|
||||
{
|
||||
return y * _width + x;
|
||||
}
|
||||
|
||||
/// The width of the image
|
||||
unsigned _width;
|
||||
int _width;
|
||||
/// The height of the image
|
||||
unsigned _height;
|
||||
int _height;
|
||||
/// The pixels of the image
|
||||
Pixel_T* _pixels;
|
||||
};
|
||||
|
@@ -178,7 +178,7 @@ void AudioGrabber::processAudioFrame(int16_t* buffer, int length)
|
||||
}
|
||||
|
||||
// Convert to Image<ColorRGB>
|
||||
Image<ColorRgb> finalImage (static_cast<unsigned>(image.width()), static_cast<unsigned>(image.height()));
|
||||
Image<ColorRgb> finalImage (image.width(),image.height());
|
||||
for (int y = 0; y < image.height(); y++)
|
||||
{
|
||||
memcpy((unsigned char*)finalImage.memptr() + y * image.width() * 3, static_cast<unsigned char*>(image.scanLine(y)), image.width() * 3);
|
||||
|
@@ -318,7 +318,7 @@ void EncoderThread::processImageMjpeg()
|
||||
}
|
||||
}
|
||||
|
||||
Image<ColorRgb> srcImage(static_cast<unsigned>(_width), static_cast<unsigned>(_height));
|
||||
Image<ColorRgb> srcImage(_width, _height);
|
||||
|
||||
if (tjDecompress2(_tjInstance, _localData , _size,
|
||||
reinterpret_cast<unsigned char*>(srcImage.memptr()), _width, 0, _height,
|
||||
|
@@ -27,7 +27,6 @@ X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
, _XRandRAvailable(false)
|
||||
, _isWayland (false)
|
||||
, _logger{}
|
||||
, _image(0,0)
|
||||
{
|
||||
_logger = Logger::getInstance("X11");
|
||||
|
||||
|
@@ -30,7 +30,6 @@ GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, i
|
||||
, _timer(new QTimer(this))
|
||||
, _updateInterval_ms(1000/updateRate_Hz)
|
||||
, _ggrabber(ggrabber)
|
||||
, _image(0,0)
|
||||
{
|
||||
GrabberWrapper::instance = this;
|
||||
|
||||
|
Reference in New Issue
Block a user