Home | Develop | Download | Contact
example_ra_color.cpp
1
33#include <Pds/Ra>
34
35
36int main(void)
37{
38 std::vector<std::vector<unsigned int>> RGB={{ 0, 0, 0},
39 {255,255,255},
40 {255, 0, 0},
41 { 0,255, 0},
42 { 0, 0,255},
43 {255,255, 0},
44 { 0,255,255},
45 {255, 0,255},
46 {191,191,191},
47 {128,128,128},
48 {128, 0, 0},
49 {128,128, 0}};
50
51 std::vector<std::vector<unsigned int>> HSL={{ 0, 0, 0},
52 { 0, 0,100},
53 { 0,100, 50},
54 {120,100, 50},
55 {240,100, 50},
56 { 60,100, 50},
57 {180,100, 50},
58 {300,100, 50},
59 { 0, 0, 75},
60 { 0, 0, 50},
61 { 0,100, 25},
62 { 60,100, 25}};
63
64
65 unsigned int i;
66 double h,s,l;
67 for(i=0;i<RGB.size();i++)
68 {
69
70 Pds::Ra::RGB2HSL(RGB[i][0],RGB[i][1],RGB[i][2],h,s,l);
71
72 std::cout<<"{"<<std::setw(3)<<RGB[i][0]<<","<<std::setw(3)<<RGB[i][1] <<","<<std::setw(3)<<RGB[i][2]<<"}";
73 std::cout<<"{"<<std::setw(3)<<HSL[i][0]<<","<<std::setw(3)<<HSL[i][1] <<","<<std::setw(3)<<HSL[i][2]<<"}";
74 std::cout<<"{"<<std::setw(3)<<round(h) <<","<<std::setw(3)<<round(s)<<","<<std::setw(3)<<round(l)<<"}";
75
76 if( (round(h)==HSL[i][0])&&(round(s)==HSL[i][1])&&(round(l)==HSL[i][2]) )
77 std::cout<<"[OK]\n";
78 else
79 std::cout<<"[ERROR]\n";
80 }
81
82
83}
void RGB2HSL(unsigned char r, unsigned char g, unsigned char b, double &h, double &s, double &l)
Transforma de coordenadas RGB a HSL

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed