All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ColorTransform.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/color/ColorTransform.cpp
22 
23  \brief Implementation of the color transform concept.
24 */
25 
26 // TerraLib
27 #include "ColorTransform.h"
28 
30 {
31  invalidate();
32 }
33 
35 {
36  m_spec = colt.m_spec;
37  m_params = colt.m_params;
38 }
39 
41 {
42  m_spec = Rgb;
43  m_params.argb.alpha = (unsigned short)(color.getAlpha() * 0x101);
44  m_params.argb.red = (unsigned short)(color.getRed() * 0x101);
45  m_params.argb.green = (unsigned short)(color.getGreen() * 0x101);
46  m_params.argb.blue = (unsigned short)(color.getBlue() * 0x101);
47  m_params.argb.pad = 0;
48 }
49 
51 {
52  m_spec = Rgb;
53  m_params.argb.alpha = (unsigned short)(((rgba >> 24) & 0xFF) * 0x101);
54  m_params.argb.red = (unsigned short)(((rgba >> 16) & 0xFF) * 0x101);
55  m_params.argb.green = (unsigned short)(((rgba >> 8) & 0xFF) * 0x101);
56  m_params.argb.blue = (unsigned short)((rgba & 0xFF) * 0x101);
57  m_params.argb.pad = 0;
58 }
59 
60 te::color::ColorTransform::ColorTransform(const int r, const int g, const int b, const int a)
61 {
62  m_spec = Rgb;
63  m_params.argb.alpha = (unsigned short)(a * 0x101);
64  m_params.argb.red = (unsigned short)(r * 0x101);
65  m_params.argb.green = (unsigned short)(g * 0x101);
66  m_params.argb.blue = (unsigned short)(b * 0x101);
67  m_params.argb.pad = 0;
68 }
69 
71 {
72 }
73 
75 {
76  m_spec = colt.m_spec;
77  m_params = colt.m_params;
78  return *this;
79 }
80 
81 
82 void te::color::ColorTransform::setRgba(int r, int g, int b, int a)
83 {
84  m_spec = Rgb;
85  m_params.argb.alpha = (unsigned short)(a * 0x101);
86  m_params.argb.red = (unsigned short)(r * 0x101);
87  m_params.argb.green = (unsigned short)(g * 0x101);
88  m_params.argb.blue = (unsigned short)(b * 0x101);
89  m_params.argb.pad = 0;
90 }
91 
93 {
94  int a = (rgba >> 24) & 0xff;
95  int r = (rgba >> 16) & 0xff;
96  int g = (rgba >> 8) & 0xff;
97  int b = rgba & 0xff;
98  setRgba(r, g, b, a);
99 }
100 
102 {
103  setRgba(cor.getRgba());
104 }
105 
106 void te::color::ColorTransform::getRgba(int* r, int* g, int* b, int* a) const
107 {
108  if (!r || !g || !b)
109  return;
110 
111  if (m_spec != Invalid && m_spec != Rgb)
112  {
113  toRgb().getRgba(r, g, b, a);
114  return;
115  }
116 
117  *r = m_params.argb.red >> 8;
118  *g = m_params.argb.green >> 8;
119  *b = m_params.argb.blue >> 8;
120 
121  if (a)
122  *a = m_params.argb.alpha >> 8;
123 }
124 
126 {
127  int r, g, b, a;
128 
129  getRgba(&r, &g, &b, &a);
130 
131  int rgba = (a << 24) + (r << 16) + (g << 8) + b;
132  return rgba;
133 }
134 
136 {
137  RGBAColor cor = getRgba();
138  return cor;
139 }
140 
142 {
143  if (m_spec != Invalid && m_spec != Rgb)
144  return toRgb().getRed();
145  return m_params.argb.red >> 8;
146 }
147 
149 {
150  if (m_spec != Invalid && m_spec != Rgb)
151  return toRgb().getGreen();
152  return m_params.argb.green >> 8;
153 }
154 
156 {
157  if (m_spec != Invalid && m_spec != Rgb)
158  return toRgb().getBlue();
159  return m_params.argb.blue >> 8;
160 }
161 
163 {
164  return m_params.argb.alpha >> 8;
165 }
166 
168 {
169  if (m_spec != Rgb)
170  setRgba(red, getGreen(), getBlue(), getAlpha());
171  else
172  m_params.argb.red = (unsigned short)(red * 0x101);
173 }
174 
176 {
177  if (m_spec != Rgb)
178  setRgba(getRed(), green, getBlue(), getAlpha());
179  else
180  m_params.argb.green = (unsigned short)(green * 0x101);
181 }
182 
184 {
185  if (m_spec != Rgb)
186  setRgba(getRed(), getGreen(), blue, getAlpha());
187  else
188  m_params.argb.blue = (unsigned short)(blue * 0x101);
189 }
190 
192 {
193  m_params.argb.alpha = (unsigned short)(alpha * 0x101);
194 }
195 
197 {
198  if (!isValid() || m_spec == Rgb)
199  return *this;
200 
201  ColorTransform colt;
202  colt.m_spec = Rgb;
203  colt.m_params.argb.alpha = m_params.argb.alpha;
204  colt.m_params.argb.pad = 0;
205 
206  switch (m_spec)
207  {
208  case Hsv:
209  {
210  if (m_params.ahsv.saturation == 0 || m_params.ahsv.hue == USHRT_MAX)
211  {
212  // achromatic case
213  colt.m_params.argb.red = colt.m_params.argb.green = colt.m_params.argb.blue = m_params.ahsv.value;
214  break;
215  }
216 
217  // chromatic case
218  const double h = m_params.ahsv.hue == 36000 ? 0 : m_params.ahsv.hue / 6000.;
219  const double s = m_params.ahsv.saturation / double(USHRT_MAX);
220  const double v = m_params.ahsv.value / double(USHRT_MAX);
221  const int i = int(h);
222  const double f = h - i;
223  const double p = v * (1.0 - s);
224 
225  if (i & 1)
226  {
227  const double q = v * (1.0 - (s * f));
228 
229  switch (i)
230  {
231  case 1:
232  colt.m_params.argb.red = (unsigned short)(round(q * USHRT_MAX));
233  colt.m_params.argb.green = (unsigned short)(round(v * USHRT_MAX));
234  colt.m_params.argb.blue = (unsigned short)(round(p * USHRT_MAX));
235  break;
236  case 3:
237  colt.m_params.argb.red = (unsigned short)(round(p * USHRT_MAX));
238  colt.m_params.argb.green = (unsigned short)(round(q * USHRT_MAX));
239  colt.m_params.argb.blue = (unsigned short)(round(v * USHRT_MAX));
240  break;
241  case 5:
242  colt.m_params.argb.red = (unsigned short)(round(v * USHRT_MAX));
243  colt.m_params.argb.green = (unsigned short)(round(p * USHRT_MAX));
244  colt.m_params.argb.blue = (unsigned short)(round(q * USHRT_MAX));
245  break;
246  }
247  }
248  else
249  {
250  const double t = v * (1.0 - (s * (1.0 - f)));
251 
252  switch (i)
253  {
254  case 0:
255  colt.m_params.argb.red = (unsigned short)(round(v * USHRT_MAX));
256  colt.m_params.argb.green = (unsigned short)(round(t * USHRT_MAX));
257  colt.m_params.argb.blue = (unsigned short)(round(p * USHRT_MAX));
258  break;
259  case 2:
260  colt.m_params.argb.red = (unsigned short)(round(p * USHRT_MAX));
261  colt.m_params.argb.green = (unsigned short)(round(v * USHRT_MAX));
262  colt.m_params.argb.blue = (unsigned short)(round(t * USHRT_MAX));
263  break;
264  case 4:
265  colt.m_params.argb.red = (unsigned short)(round(t * USHRT_MAX));
266  colt.m_params.argb.green = (unsigned short)(round(p * USHRT_MAX));
267  colt.m_params.argb.blue = (unsigned short)(round(v * USHRT_MAX));
268  break;
269  }
270  }
271  break;
272  }
273  case Hsl:
274  {
275  if (m_params.ahsl.saturation == 0 || m_params.ahsl.hue == USHRT_MAX)
276  {
277  // achromatic case
278  colt.m_params.argb.red = colt.m_params.argb.green = colt.m_params.argb.blue = m_params.ahsl.lightness;
279  }
280  else if (m_params.ahsl.lightness == 0)
281  {
282  // lightness 0
283  colt.m_params.argb.red = colt.m_params.argb.green = colt.m_params.argb.blue = 0;
284  }
285  else
286  {
287  // chromatic case
288  const double h = m_params.ahsl.hue == 36000 ? 0 : m_params.ahsl.hue / 36000.;
289  const double s = m_params.ahsl.saturation / double(USHRT_MAX);
290  const double l = m_params.ahsl.lightness / double(USHRT_MAX);
291 
292  double temp2;
293  if (l < double(0.5))
294  temp2 = l * (double(1.0) + s);
295  else
296  temp2 = l + s - (l * s);
297 
298  const double temp1 = (double(2.0) * l) - temp2;
299  double temp3[3] = { h + (double(1.0) / double(3.0)), h, h - (double(1.0) / double(3.0)) };
300 
301  for (int i = 0; i != 3; ++i)
302  {
303  if (temp3[i] < double(0.0))
304  temp3[i] += double(1.0);
305  else if (temp3[i] > double(1.0))
306  temp3[i] -= double(1.0);
307 
308  const double sixtemp3 = temp3[i] * double(6.0);
309  if (sixtemp3 < double(1.0))
310  colt.m_params.array[i+1] = (unsigned short)(round((temp1 + (temp2 - temp1) * sixtemp3) * USHRT_MAX));
311  else if ((temp3[i] * double(2.0)) < double(1.0))
312  colt.m_params.array[i+1] = (unsigned short)(round(temp2 * USHRT_MAX));
313  else if ((temp3[i] * double(3.0)) < double(2.0))
314  colt.m_params.array[i+1] = (unsigned short)(round((temp1 + (temp2 -temp1) * (double(2.0) /double(3.0) - temp3[i]) * double(6.0)) * USHRT_MAX));
315  else
316  colt.m_params.array[i+1] = (unsigned short)(round(temp1 * USHRT_MAX));
317  }
318  colt.m_params.argb.red = colt.m_params.argb.red == 1 ? 0 : colt.m_params.argb.red;
319  colt.m_params.argb.green = colt.m_params.argb.green == 1 ? 0 : colt.m_params.argb.green;
320  colt.m_params.argb.blue = colt.m_params.argb.blue == 1 ? 0 : colt.m_params.argb.blue;
321  }
322  break;
323  }
324  case Cmyk:
325  {
326  const double c = m_params.acmyk.cyan / double(USHRT_MAX);
327  const double m = m_params.acmyk.magenta / double(USHRT_MAX);
328  const double y = m_params.acmyk.yellow / double(USHRT_MAX);
329  const double k = m_params.acmyk.black / double(USHRT_MAX);
330 
331  colt.m_params.argb.red = (unsigned short)(round((1.0 - (c * (1.0 - k) + k)) * USHRT_MAX));
332  colt.m_params.argb.green = (unsigned short)(round((1.0 - (m * (1.0 - k) + k)) * USHRT_MAX));
333  colt.m_params.argb.blue = (unsigned short)(round((1.0 - (y * (1.0 - k) + k)) * USHRT_MAX));
334  break;
335  }
336  default:
337  break;
338  }
339 
340  return colt;
341 }
342 
343 #define MAX_3(a, b, c) ( ( a > b && a > c) ? a : (b > c ? b : c) )
344 #define MIN_3(a, b, c) ( ( a < b && a < c) ? a : (b < c ? b : c) )
345 
347 {
348  if (!isValid() || m_spec == Hsv)
349  return *this;
350 
351  if (m_spec != Rgb)
352  return toRgb().toHsv();
353 
354  ColorTransform colt;
355  colt.m_spec = Hsv;
356  colt.m_params.ahsv.alpha = m_params.argb.alpha;
357  colt.m_params.ahsv.pad = 0;
358 
359  const double r = m_params.argb.red / double(USHRT_MAX);
360  const double g = m_params.argb.green / double(USHRT_MAX);
361  const double b = m_params.argb.blue / double(USHRT_MAX);
362  const double max = MAX_3(r, g, b);
363  const double min = MIN_3(r, g, b);
364  const double delta = max - min;
365  colt.m_params.ahsv.value = (unsigned short)(round(max * USHRT_MAX));
366 
367  if (fuzzyIsNull(delta))
368  {
369  // achromatic case, hue is undefined
370  colt.m_params.ahsv.hue = USHRT_MAX;
371  colt.m_params.ahsv.saturation = 0;
372  }
373  else
374  {
375  // chromatic case
376  double hue = 0;
377  colt.m_params.ahsv.saturation = (unsigned short)(round((delta / max) * USHRT_MAX));
378  if (fuzzyCompare(r, max))
379  {
380  hue = ((g - b) /delta);
381  }
382  else if (fuzzyCompare(g, max))
383  {
384  hue = (2.0 + (b - r) / delta);
385  }
386  else if (fuzzyCompare(b, max))
387  {
388  hue = (4.0 + (r - g) / delta);
389  }
390  else
391  {
392 // "internal error"
393  }
394  hue *= 60.0;
395 
396  if (hue < 0.0)
397  hue += 360.0;
398  colt.m_params.ahsv.hue = (unsigned short)(round(hue * 100));
399  }
400 
401  return colt;
402 }
403 
405 {
406  if (!isValid() || m_spec == Hsl)
407  return *this;
408 
409  if (m_spec != Rgb)
410  return toRgb().toHsl();
411 
412  ColorTransform colt;
413  colt.m_spec = Hsl;
414  colt.m_params.ahsl.alpha = m_params.argb.alpha;
415  colt.m_params.ahsl.pad = 0;
416 
417  const double r = m_params.argb.red / double(USHRT_MAX);
418  const double g = m_params.argb.green / double(USHRT_MAX);
419  const double b = m_params.argb.blue / double(USHRT_MAX);
420  const double max = MAX_3(r, g, b);
421  const double min = MIN_3(r, g, b);
422  const double delta = max - min;
423  const double delta2 = max + min;
424  const double lightness = double(0.5) * delta2;
425  colt.m_params.ahsl.lightness = (unsigned short)(round(lightness * USHRT_MAX));
426 
427  if (fuzzyIsNull(delta))
428  {
429  // achromatic case, hue is undefined
430  colt.m_params.ahsl.hue = 0;
431  colt.m_params.ahsl.saturation = 0;
432  }
433  else
434  {
435  // chromatic case
436  double hue = 0;
437  if (lightness < double(0.5))
438  colt.m_params.ahsl.saturation = (unsigned short)(round((delta / delta2) * USHRT_MAX));
439  else
440  colt.m_params.ahsl.saturation = (unsigned short)(round((delta / (double(2.0) - delta2)) * USHRT_MAX));
441 
442  if (fuzzyCompare(r, max))
443  {
444  hue = ((g - b) /delta);
445  }
446  else if (fuzzyCompare(g, max))
447  {
448  hue = (2.0 + (b - r) / delta);
449  }
450  else if (fuzzyCompare(b, max))
451  {
452  hue = (4.0 + (r - g) / delta);
453  }
454  else
455  {
456 // "internal error"
457  }
458 
459  hue *= 60.0;
460  if (hue < 0.0)
461  hue += 360.0;
462  colt.m_params.ahsl.hue = (unsigned short)(round(hue * 100));
463  }
464 
465  return colt;
466 }
467 
469 {
470  if (!isValid() || m_spec == Cmyk)
471  return *this;
472 
473  if (m_spec != Rgb)
474  return toRgb().toCmyk();
475 
476  ColorTransform colt;
477  colt.m_spec = Cmyk;
478  colt.m_params.acmyk.alpha = m_params.argb.alpha;
479 
480  // rgb -> cmy
481  const double r = m_params.argb.red / double(USHRT_MAX);
482  const double g = m_params.argb.green / double(USHRT_MAX);
483  const double b = m_params.argb.blue / double(USHRT_MAX);
484  double c = 1.0 - r;
485  double m = 1.0 - g;
486  double y = 1.0 - b;
487 
488  // cmy -> cmyk
489  const double k = vMin(c, vMin(m, y));
490 
491  if (!fuzzyIsNull(k - 1))
492  {
493  c = (c - k) / (1.0 - k);
494  m = (m - k) / (1.0 - k);
495  y = (y - k) / (1.0 - k);
496  }
497 
498  colt.m_params.acmyk.cyan = (unsigned short)(round(c * USHRT_MAX));
499  colt.m_params.acmyk.magenta = (unsigned short)(round(m * USHRT_MAX));
500  colt.m_params.acmyk.yellow = (unsigned short)(round(y * USHRT_MAX));
501  colt.m_params.acmyk.black = (unsigned short)(round(k * USHRT_MAX));
502 
503  return colt;
504 }
505 
507 {
508  if (m_spec != Invalid && m_spec != Hsv)
509  return toHsv().getHsvHue();
510  return m_params.ahsv.hue == USHRT_MAX ? -1 : m_params.ahsv.hue / 100;
511 }
512 
514 {
515  if (m_spec != Invalid && m_spec != Hsv)
516  return toHsv().getHsvSaturation();
517  return m_params.ahsv.saturation >> 8;
518 }
519 
521 {
522  if (m_spec != Invalid && m_spec != Hsv)
523  return toHsv().getValue();
524  return m_params.ahsv.value >> 8;
525 }
526 
527 void te::color::ColorTransform::getHsv(int *h, int *s, int *v, int *a) const
528 {
529  if (!h || !s || !v)
530  return;
531 
532  if (m_spec != Invalid && m_spec != Hsv)
533  {
534  toHsv().getHsv(h, s, v, a);
535  return;
536  }
537 
538  *h = m_params.ahsv.hue == USHRT_MAX ? -1 : m_params.ahsv.hue / 100;
539  *s = m_params.ahsv.saturation >> 8;
540  *v = m_params.ahsv.value >> 8;
541 
542  if (a)
543  *a = m_params.ahsv.alpha >> 8;
544 }
545 
546 void te::color::ColorTransform::setHsv(int h, int s, int v, int a)
547 {
548  if (h < -1 || (unsigned int)s > 255 || (unsigned int)v > 255 || (unsigned int)a > 255)
549  {
550  //"HSV parameters out of range"
551  invalidate();
552  return;
553  }
554 
555  m_spec = Hsv;
556  m_params.ahsv.alpha = (unsigned short)(a * 0x101);
557  m_params.ahsv.hue = (unsigned short)(h == -1 ? USHRT_MAX : (h % 360) * 100);
558  m_params.ahsv.saturation = (unsigned short)(s * 0x101);
559  m_params.ahsv.value = (unsigned short)(v * 0x101);
560  m_params.ahsv.pad = 0;
561 }
562 
564 {
565  if (m_spec != Invalid && m_spec != Cmyk)
566  return toCmyk().getCyan();
567  return m_params.acmyk.cyan >> 8;
568 }
569 
571 {
572  if (m_spec != Invalid && m_spec != Cmyk)
573  return toCmyk().getMagenta();
574  return m_params.acmyk.magenta >> 8;
575 }
576 
578 {
579  if (m_spec != Invalid && m_spec != Cmyk)
580  return toCmyk().getYellow();
581  return m_params.acmyk.yellow >> 8;
582 }
583 
585 {
586  if (m_spec != Invalid && m_spec != Cmyk)
587  return toCmyk().getBlack();
588  return m_params.acmyk.black >> 8;
589 }
590 
591 void te::color::ColorTransform::getCmyk(int *c, int *m, int *y, int *k, int *a)
592 {
593  if (!c || !m || !y || !k)
594  return;
595 
596  if (m_spec != Invalid && m_spec != Cmyk)
597  {
598  toCmyk().getCmyk(c, m, y, k, a);
599  return;
600  }
601 
602  *c = m_params.acmyk.cyan >> 8;
603  *m = m_params.acmyk.magenta >> 8;
604  *y = m_params.acmyk.yellow >> 8;
605  *k = m_params.acmyk.black >> 8;
606 
607  if (a)
608  *a = m_params.acmyk.alpha >> 8;
609 }
610 
611 void te::color::ColorTransform::setCmyk(int c, int m, int y, int k, int a)
612 {
613  if (c < 0 || c > 255
614  || m < 0 || m > 255
615  || y < 0 || y > 255
616  || k < 0 || k > 255
617  || a < 0 || a > 255)
618  {
619  //"CMYK parameters out of range"
620  return;
621  }
622 
623  m_spec = Cmyk;
624  m_params.acmyk.alpha = (unsigned short)(a * 0x101);
625  m_params.acmyk.cyan = (unsigned short)(c * 0x101);
626  m_params.acmyk.magenta = (unsigned short)(m * 0x101);
627  m_params.acmyk.yellow = (unsigned short)(y * 0x101);
628  m_params.acmyk.black = (unsigned short)(k * 0x101);
629 }
630 
632 {
633  if (m_spec != Invalid && m_spec != Hsl)
634  return toHsl().getHslHue();
635  return m_params.ahsl.hue == USHRT_MAX ? -1 : m_params.ahsl.hue / 100;
636 }
637 
639 {
640  if (m_spec != Invalid && m_spec != Hsl)
641  return toHsl().getHslSaturation();
642  return m_params.ahsl.saturation >> 8;
643 }
644 
646 {
647  if (m_spec != Invalid && m_spec != Hsl)
648  return toHsl().getLightness();
649  return m_params.ahsl.lightness >> 8;
650 }
651 
652 void te::color::ColorTransform::getHsl(int *h, int *s, int *l, int *a) const
653 {
654  if (!h || !s || !l)
655  return;
656 
657  if (m_spec != Invalid && m_spec != Hsl)
658  {
659  toHsl().getHsl(h, s, l, a);
660  return;
661  }
662 
663  *h = m_params.ahsl.hue == USHRT_MAX ? -1 : m_params.ahsl.hue / 100;
664  *s = m_params.ahsl.saturation >> 8;
665  *l = m_params.ahsl.lightness >> 8;
666 
667  if (a)
668  *a = m_params.ahsl.alpha >> 8;
669 }
670 
671 void te::color::ColorTransform::setHsl(int h, int s, int l, int a)
672 {
673  if (h < -1 || (unsigned short)s > 255 || (unsigned short)l > 255 || (unsigned short)a > 255)
674  {
675  //"HSV parameters out of range"
676  invalidate();
677  return;
678  }
679 
680  m_spec = Hsl;
681  m_params.ahsl.alpha = (unsigned short)(a * 0x101);
682  m_params.ahsl.hue = (unsigned short)(h == -1 ? USHRT_MAX : (h % 360) * 100);
683  m_params.ahsl.saturation = (unsigned short)(s * 0x101);
684  m_params.ahsl.lightness = (unsigned short)(l * 0x101);
685  m_params.ahsl.pad = 0;
686 }
687 
689 {
690  if (m_spec == Hsl && m_spec == colt.m_spec)
691  {
692  return (m_params.argb.alpha == colt.m_params.argb.alpha
693  && ((((m_params.ahsl.hue % 36000) == (colt.m_params.ahsl.hue % 36000)))
694  || (m_params.ahsl.hue == colt.m_params.ahsl.hue))
695  && (abs(m_params.ahsl.saturation - colt.m_params.ahsl.saturation) < 50
696  || m_params.ahsl.lightness == 0
697  || colt.m_params.ahsl.lightness == 0
698  || m_params.ahsl.lightness == USHRT_MAX
699  || colt.m_params.ahsl.lightness == USHRT_MAX)
700  && (abs(m_params.ahsl.lightness - colt.m_params.ahsl.lightness)) < 50);
701  }
702  else
703  {
704  return (m_spec == colt.m_spec
705  && m_params.argb.alpha == colt.m_params.argb.alpha
706  && (((m_spec == Hsv)
707  && ((m_params.ahsv.hue % 36000) == (colt.m_params.ahsv.hue % 36000)))
708  || (m_params.ahsv.hue == colt.m_params.ahsv.hue))
709  && m_params.argb.green == colt.m_params.argb.green
710  && m_params.argb.blue == colt.m_params.argb.blue
711  && m_params.argb.pad == colt.m_params.argb.pad);
712  }
713 }
714 
716 {
717  return !operator==(colt);
718 }
719 
void getHsl(int *h, int *s, int *l, int *a=0) const
It gets the h, s, l components of this color.
int getValue() const
It returns the value component of this color.
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
Definition: RGBAColor.h:315
#define MIN_3(a, b, c)
int getHsvHue() const
It returns the hue component of this color.
union te::color::ColorTransform::@0 m_params
struct te::color::ColorTransform::@0::@1 argb
int getHslSaturation() const
It returns the saturation component of this color.
te::color::ColorTransform & operator=(const ColorTransform &colt)
Assigns a copy of a color transform and returns a reference to it.
int getRed() const
It returns the red component color value (a value from 0 to 255).
Definition: RGBAColor.h:295
void setRgba(int r, int g, int b, int a)
It sets the color.
te::da::Expression * operator==(const te::da::Expression &e1, const te::da::Expression &e2)
Definition: Expression.cpp:38
int getLightness() const
It returns the lightness component of this color.
bool operator!=(const ColorTransform &colt) const
It compares the color tranforms are different.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
Definition: RGBAColor.h:305
void setCmyk(int c, int m, int y, int k, int a=255)
It sets the c, m, y, k components of this color.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
Definition: RGBAColor.h:300
ColorTransform()
Default constructor of a new color.
int getHsvSaturation() const
It returns the saturation component of this color.
int getRed() const
It returns the red component.
int getAlpha() const
It returns the alpha component.
void setColor(const RGBAColor &cor)
It sets the color.
void setHsv(int h, int s, int v, int a=255)
It sets the h, s, v components of this color.
void setBlue(int blue)
It sets the blue component.
te::color::RGBAColor getColor() const
It returns the RGBA color.
void invalidate()
Marks the color transform as invalid and sets all components to zero (alpha is set to fully opaque)...
void setGreen(int green)
It sets the green component.
te::color::ColorTransform toHsv() const
It returns the color tranform in Hsv spec.
#define MAX_3(a, b, c)
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
Definition: RGBAColor.h:310
int getHslHue() const
It returns the hue component of this color.
te::color::ColorTransform toRgb() const
It returns the color tranform in Rgb spec.
void setAlpha(int alpha)
It sets the alpha component.
int getBlack() const
It gets the black component of this color.
void setHsl(int h, int s, int l, int a=255)
It sets the h, s, l components of this color.
void getCmyk(int *c, int *m, int *y, int *k, int *a=0)
It gets the c, m, y, k components of this color.
struct te::color::ColorTransform::@0::@2 ahsv
int getYellow() const
It gets the yellow component of this color.
int getRgba() const
It returns the color value (0xAARRGGBB).
A class to transform .
unsigned short array[5]
te::color::ColorTransform toHsl() const
It returns the color tranform in Hsl spec.
int getCyan() const
It gets the cyan component of this color.
int getMagenta() const
It gets the magenta component of this color.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
te::color::ColorTransform toCmyk() const
It returns the color tranform in Cmyk spec.
void getHsv(int *h, int *s, int *v, int *a=0) const
It gets the h, s, v components of this color.
bool operator==(const ColorTransform &colt) const
It compares the color tranforms are iqual.
A class to transform RGBA color to HSV, HSL and CMYK.
int getBlue() const
It returns the blue component.
void setRed(int red)
It sets the red component.
struct te::color::ColorTransform::@0::@3 acmyk
int getGreen() const
It returns the green component.
struct te::color::ColorTransform::@0::@4 ahsl