mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Changed RgbImage to template based Image (with template for pixel type)
Former-commit-id: ef02f164eaf3c2f9dd552c1c17b525cf6eed499c
This commit is contained in:
@@ -4,13 +4,16 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/utils)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/utils)
|
||||
|
||||
add_library(hyperion-utils
|
||||
${CURRENT_HEADER_DIR}/RgbColor.h
|
||||
${CURRENT_HEADER_DIR}/RgbImage.h
|
||||
${CURRENT_HEADER_DIR}/ColorArgb.h
|
||||
${CURRENT_SOURCE_DIR}/ColorArgb.cpp
|
||||
${CURRENT_HEADER_DIR}/ColorRgb.h
|
||||
${CURRENT_SOURCE_DIR}/ColorRgb.cpp
|
||||
${CURRENT_HEADER_DIR}/ColorRgba.h
|
||||
${CURRENT_SOURCE_DIR}/ColorRgba.cpp
|
||||
${CURRENT_HEADER_DIR}/Image.h
|
||||
${CURRENT_HEADER_DIR}/ColorTransform.h
|
||||
${CURRENT_HEADER_DIR}/HsvTransform.h
|
||||
|
||||
${CURRENT_SOURCE_DIR}/RgbColor.cpp
|
||||
${CURRENT_SOURCE_DIR}/RgbImage.cpp
|
||||
${CURRENT_SOURCE_DIR}/ColorTransform.cpp
|
||||
${CURRENT_SOURCE_DIR}/HsvTransform.cpp
|
||||
|
||||
|
10
libsrc/utils/ColorArgb.cpp
Normal file
10
libsrc/utils/ColorArgb.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorArgb.h>
|
||||
|
||||
ColorArgb ColorArgb::BLACK = { 255, 0, 0, 0 };
|
||||
ColorArgb ColorArgb::RED = { 255, 255, 0, 0 };
|
||||
ColorArgb ColorArgb::GREEN = { 255, 0, 255, 0 };
|
||||
ColorArgb ColorArgb::BLUE = { 255, 0, 0, 255 };
|
||||
ColorArgb ColorArgb::YELLOW= { 255, 255, 255, 0 };
|
||||
ColorArgb ColorArgb::WHITE = { 255, 255, 255, 255 };
|
10
libsrc/utils/ColorRgb.cpp
Normal file
10
libsrc/utils/ColorRgb.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
// Local includes
|
||||
#include <utils/ColorRgb.h>
|
||||
|
||||
ColorRgb ColorRgb::BLACK = { 0, 0, 0 };
|
||||
ColorRgb ColorRgb::RED = { 255, 0, 0 };
|
||||
ColorRgb ColorRgb::GREEN = { 0, 255, 0 };
|
||||
ColorRgb ColorRgb::BLUE = { 0, 0, 255 };
|
||||
ColorRgb ColorRgb::YELLOW= { 255, 255, 0 };
|
||||
ColorRgb ColorRgb::WHITE = { 255, 255, 255 };
|
10
libsrc/utils/ColorRgba.cpp
Normal file
10
libsrc/utils/ColorRgba.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorRgba.h>
|
||||
|
||||
ColorRgba ColorRgba::BLACK = { 0, 0, 0, 255 };
|
||||
ColorRgba ColorRgba::RED = { 255, 0, 0, 255 };
|
||||
ColorRgba ColorRgba::GREEN = { 0, 255, 0, 255 };
|
||||
ColorRgba ColorRgba::BLUE = { 0, 0, 255, 255 };
|
||||
ColorRgba ColorRgba::YELLOW= { 255, 255, 0, 255 };
|
||||
ColorRgba ColorRgba::WHITE = { 255, 255, 255, 255 };
|
@@ -1,10 +0,0 @@
|
||||
|
||||
// Local includes
|
||||
#include <utils/RgbColor.h>
|
||||
|
||||
RgbColor RgbColor::BLACK = { 0, 0, 0 };
|
||||
RgbColor RgbColor::RED = { 255, 0, 0 };
|
||||
RgbColor RgbColor::GREEN = { 0, 255, 0 };
|
||||
RgbColor RgbColor::BLUE = { 0, 0, 255 };
|
||||
RgbColor RgbColor::YELLOW= { 255, 255, 0 };
|
||||
RgbColor RgbColor::WHITE = { 255, 255, 255 };
|
@@ -1,50 +0,0 @@
|
||||
|
||||
// STL includes
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
// hyperion Utils includes
|
||||
#include <utils/RgbImage.h>
|
||||
|
||||
|
||||
RgbImage::RgbImage(const unsigned width, const unsigned height, const RgbColor background) :
|
||||
_width(width),
|
||||
_height(height),
|
||||
mColors(new RgbColor[width*height])
|
||||
{
|
||||
for (unsigned i=0; i<width*height; ++i)
|
||||
{
|
||||
mColors[i] = background;
|
||||
}
|
||||
}
|
||||
|
||||
RgbImage::~RgbImage()
|
||||
{
|
||||
delete[] mColors;
|
||||
}
|
||||
|
||||
void RgbImage::setPixel(const unsigned x, const unsigned y, const RgbColor color)
|
||||
{
|
||||
// Debug-mode sanity check on given index
|
||||
(*this)(x,y) = color;
|
||||
}
|
||||
|
||||
const RgbColor& RgbImage::operator()(const unsigned x, const unsigned y) const
|
||||
{
|
||||
// Debug-mode sanity check on given index
|
||||
assert(x < _width);
|
||||
assert(y < _height);
|
||||
|
||||
const unsigned index = toIndex(x, y);
|
||||
return mColors[index];
|
||||
}
|
||||
|
||||
RgbColor& RgbImage::operator()(const unsigned x, const unsigned y)
|
||||
{
|
||||
// Debug-mode sanity check on given index
|
||||
assert(x < _width);
|
||||
assert(y < _height);
|
||||
|
||||
const unsigned index = toIndex(x, y);
|
||||
return mColors[index];
|
||||
}
|
Reference in New Issue
Block a user