Programa para el testeo de las funciones.
Programa para el testeo de las funciones.Para compilar o código example_ra_color.cpp:
g++ -static -o example_ra_color example_ra_color.cpp -lpdsramm
Para executar o programa:
Retornando por consola:
{ 0, 0, 0}{ 0, 0, 0}{ 0, 0, 0}[OK]
{255,255,255}{ 0, 0,100}{ 0, 0,100}[OK]
{255, 0, 0}{ 0,100, 50}{ 0,100, 50}[OK]
{ 0,255, 0}{120,100, 50}{120,100, 50}[OK]
{ 0, 0,255}{240,100, 50}{240,100, 50}[OK]
{255,255, 0}{ 60,100, 50}{ 60,100, 50}[OK]
{ 0,255,255}{180,100, 50}{180,100, 50}[OK]
{255, 0,255}{300,100, 50}{300,100, 50}[OK]
{191,191,191}{ 0, 0, 75}{ 0, 0, 75}[OK]
{128,128,128}{ 0, 0, 50}{ 0, 0, 50}[OK]
{128, 0, 0}{ 0,100, 25}{ 0,100, 25}[OK]
{128,128, 0}{ 60,100, 25}{ 60,100, 25}[OK]
Código example_ra_color.cpp:
#include <Pds/Ra>
int main(void)
{
std::vector<std::vector<unsigned int>> RGB={{ 0, 0, 0},
{255,255,255},
{255, 0, 0},
{ 0,255, 0},
{ 0, 0,255},
{255,255, 0},
{ 0,255,255},
{255, 0,255},
{191,191,191},
{128,128,128},
{128, 0, 0},
{128,128, 0}};
std::vector<std::vector<unsigned int>> HSL={{ 0, 0, 0},
{ 0, 0,100},
{ 0,100, 50},
{120,100, 50},
{240,100, 50},
{ 60,100, 50},
{180,100, 50},
{300,100, 50},
{ 0, 0, 75},
{ 0, 0, 50},
{ 0,100, 25},
{ 60,100, 25}};
unsigned int i;
double h,s,l;
for(i=0;i<RGB.size();i++)
{
std::cout<<"{"<<std::setw(3)<<RGB[i][0]<<","<<std::setw(3)<<RGB[i][1] <<","<<std::setw(3)<<RGB[i][2]<<"}";
std::cout<<"{"<<std::setw(3)<<HSL[i][0]<<","<<std::setw(3)<<HSL[i][1] <<","<<std::setw(3)<<HSL[i][2]<<"}";
std::cout<<"{"<<std::setw(3)<<round(h) <<","<<std::setw(3)<<round(s)<<","<<std::setw(3)<<round(l)<<"}";
if( (round(h)==HSL[i][0])&&(round(s)==HSL[i][1])&&(round(l)==HSL[i][2]) )
std::cout<<"[OK]\n";
else
std::cout<<"[ERROR]\n";
}
}
void RGB2HSL(unsigned char r, unsigned char g, unsigned char b, double &h, double &s, double &l)
Transforma de coordenadas RGB a HSL