mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
* Refactor to fix #1671 * Add GUI/NonGUI mode to info page * Do not show lock config, if in non-UI mode * Updae Changelog * Correct includes * Ensure key member initialization - RGB Channels * Ensure key member initialization - WebServer * Update RGBChannels * Fix initialization order * Fix key when inserting new logger in LoggerMap, Prepare logBuffer-JSON snapshot view in LoggerManager, Increase buffered loglines to 500 * Fix Memory leak in GrabberWrapper * Fix Memory leak in BlackBorderProcessor * Fix Memory leak in BlackBorderProcessor * use ninja generator under macos * Fix BGEffectHandler destruction * Fix Mdns code * Clear list after applying qDeleteAll * Fix deletion of CecHandler * Fix memory leak caused by wrong buffer allocation * Remove extra pixel consistently * Change mDNS to Qt SmartPointers * Correct removal * Fix usage of _width/_height (they are the output resolution, not the screen resolution) That avoids unnecessary resizing of the output image with every transferFrame call * Move main non Thread Objects to Smart Pointers * Revert "Move main non Thread Objects to Smart Pointers" This reverts commit 26102ca963982e2fbc4ffb8d4db6139f0128a3cc. * Add missing deletes * Revert MdnsBrowser chnage * Revert MdnsBrowser change * Fix memory leaks related standalone grabber * Address CodeQL finding * delete pointer OsxFrameGrabber --------- Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
208 lines
3.5 KiB
C++
208 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include <QSharedDataPointer>
|
|
|
|
#include <utils/ImageData.h>
|
|
|
|
template <typename Pixel_T>
|
|
class Image
|
|
{
|
|
public:
|
|
typedef Pixel_T pixel_type;
|
|
|
|
Image() :
|
|
Image(1, 1, Pixel_T())
|
|
{
|
|
}
|
|
|
|
Image(int width, int height) :
|
|
Image(width, height, Pixel_T())
|
|
{
|
|
}
|
|
|
|
///
|
|
/// Constructor for an image with specified width and height
|
|
///
|
|
/// @param width The width of the image
|
|
/// @param height The height of the image
|
|
/// @param background The color of the image
|
|
///
|
|
Image(int width, int height, const Pixel_T background) :
|
|
_d_ptr(new ImageData<Pixel_T>(width, height, background))
|
|
{
|
|
}
|
|
|
|
///
|
|
/// Copy constructor for an image
|
|
/// @param other The image which will be copied
|
|
///
|
|
Image(const Image & other)
|
|
{
|
|
_d_ptr = other._d_ptr;
|
|
}
|
|
|
|
Image& operator=(Image rhs)
|
|
{
|
|
// Define assignment operator in terms of the copy constructor
|
|
// More to read: https://stackoverflow.com/questions/255612/dynamically-allocating-an-array-of-objects?answertab=active#tab-top
|
|
_d_ptr = rhs._d_ptr;
|
|
return *this;
|
|
}
|
|
|
|
void swap(Image& s)
|
|
{
|
|
std::swap(this->_d_ptr, s._d_ptr);
|
|
}
|
|
|
|
Image(Image&& src) noexcept
|
|
{
|
|
std::swap(this->_d_ptr, src._d_ptr);
|
|
}
|
|
|
|
Image& operator=(Image&& src) noexcept
|
|
{
|
|
src.swap(*this);
|
|
return *this;
|
|
}
|
|
|
|
///
|
|
/// Destructor
|
|
///
|
|
~Image()
|
|
{
|
|
}
|
|
|
|
///
|
|
/// Returns the width of the image
|
|
///
|
|
/// @return The width of the image
|
|
///
|
|
inline int width() const
|
|
{
|
|
return _d_ptr->width();
|
|
}
|
|
|
|
///
|
|
/// Returns the height of the image
|
|
///
|
|
/// @return The height of the image
|
|
///
|
|
inline int height() const
|
|
{
|
|
return _d_ptr->height();
|
|
}
|
|
|
|
uint8_t red(unsigned pixel) const
|
|
{
|
|
return _d_ptr->red(pixel);
|
|
}
|
|
|
|
uint8_t green(unsigned pixel) const
|
|
{
|
|
return _d_ptr->green(pixel);
|
|
}
|
|
|
|
///
|
|
/// Returns a const reference to a specified pixel in the image
|
|
///
|
|
/// @param x The x index
|
|
/// @param y The y index
|
|
///
|
|
/// @return const reference to specified pixel
|
|
///
|
|
uint8_t blue(int pixel) const
|
|
{
|
|
return _d_ptr->blue(pixel);
|
|
}
|
|
|
|
///
|
|
/// Returns a reference to a specified pixel in the image
|
|
///
|
|
/// @param x The x index
|
|
/// @param y The y index
|
|
const Pixel_T& operator()(int x, int y) const
|
|
{
|
|
return _d_ptr->operator()(x, y);
|
|
}
|
|
|
|
///
|
|
/// @return reference to specified pixel
|
|
///
|
|
Pixel_T& operator()(int x, int y)
|
|
{
|
|
return _d_ptr->operator()(x, y);
|
|
}
|
|
|
|
/// Resize the image
|
|
/// @param width The width of the image
|
|
/// @param height The height of the image
|
|
void resize(int width, int height)
|
|
{
|
|
_d_ptr->resize(width, height);
|
|
}
|
|
|
|
///
|
|
/// Returns a memory pointer to the first pixel in the image
|
|
/// @return The memory pointer to the first pixel
|
|
///
|
|
Pixel_T* memptr()
|
|
{
|
|
return _d_ptr->memptr();
|
|
}
|
|
|
|
///
|
|
/// Returns a const memory pointer to the first pixel in the image
|
|
/// @return The const memory pointer to the first pixel
|
|
///
|
|
const Pixel_T* memptr() const
|
|
{
|
|
return _d_ptr->memptr();
|
|
}
|
|
|
|
///
|
|
/// Convert image of any color order to a RGB image.
|
|
///
|
|
/// @param[out] image The image that buffers the output
|
|
///
|
|
void toRgb(Image<ColorRgb>& image) const
|
|
{
|
|
_d_ptr->toRgb(*image._d_ptr);
|
|
}
|
|
|
|
///
|
|
/// Get size of buffer
|
|
///
|
|
ssize_t size() const
|
|
{
|
|
return _d_ptr->size();
|
|
}
|
|
|
|
///
|
|
/// Clear the image
|
|
///
|
|
void clear()
|
|
{
|
|
_d_ptr->clear();
|
|
}
|
|
|
|
private:
|
|
template<class T>
|
|
friend class Image;
|
|
|
|
///
|
|
/// Translate x and y coordinate to index of the underlying vector
|
|
///
|
|
/// @param x The x index
|
|
/// @param y The y index
|
|
///
|
|
/// @return The index into the underlying data-vector
|
|
///
|
|
inline int toIndex(int x, int y) const
|
|
{
|
|
return _d_ptr->toIndex(x, y);
|
|
}
|
|
|
|
QSharedDataPointer<ImageData<Pixel_T>> _d_ptr;
|
|
};
|
|
|