SAGA API  v9.2
api_colors.cpp
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // api_colors.cpp //
15 // //
16 // Copyright (C) 2005 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Goettingen //
44 // Goldschmidtstr. 5 //
45 // 37077 Goettingen //
46 // Germany //
47 // //
48 // e-mail: oconrad@saga-gis.org //
49 // //
51 
52 //---------------------------------------------------------
53 #include <stdlib.h>
54 #include <string.h>
55 
56 #include "api_core.h"
57 #include "mat_tools.h"
58 
59 
61 // //
62 // //
63 // //
65 
66 //---------------------------------------------------------
68 {
69  return( CSG_Colors::Get_Predefined_Name(Index) );
70 }
71 
72 //---------------------------------------------------------
74 {
76 }
77 
78 //---------------------------------------------------------
79 bool SG_Color_From_Text (const CSG_String &Text, long &Color)
80 { // from wx/src/common/colourcmn.cpp, hexadecimal prefixed with # ("HTML syntax") see https://drafts.csswg.org/css-color/#hex-notation
81 
82  if( Text.is_Empty() || Text.Get_Char(0) != L'#' )
83  {
84  return( false );
85  }
86 
87  const char *s = Text.b_str(); unsigned long c;
88 
89  if( sscanf(s + 1, "%lx", &c) == 1 )
90  {
91  switch( Text.Length() - 1 )
92  {
93  case 6: // #rrggbb
94  c = (c << 8) + 0xFF;
95  Color = SG_GET_RGB(
96  (unsigned char)((c >> 24) & 0xFF),
97  (unsigned char)((c >> 16) & 0xFF),
98  (unsigned char)((c >> 8) & 0xFF)
99  );
100  return( true );
101 
102  case 8: // #rrggbbaa
103  Color = SG_GET_RGBA(
104  (unsigned char)((c >> 24) & 0xFF),
105  (unsigned char)((c >> 16) & 0xFF),
106  (unsigned char)((c >> 8) & 0xFF),
107  (unsigned char)((c ) & 0xFF)
108  );
109  return( true );
110 
111  case 3: // #rgb
112  c = (c << 4) + 0xF;
113  Color = SG_GET_RGB(
114  (unsigned char)(((c >> 12) & 0xF) * 0x11),
115  (unsigned char)(((c >> 8) & 0xF) * 0x11),
116  (unsigned char)(((c >> 4) & 0xF) * 0x11)
117  );
118  return( true );
119 
120  case 4: // #rgba
121  Color = SG_GET_RGBA(
122  (unsigned char)(((c >> 12) & 0xF) * 0x11),
123  (unsigned char)(((c >> 8) & 0xF) * 0x11),
124  (unsigned char)(((c >> 4) & 0xF) * 0x11),
125  (unsigned char)(((c ) & 0xF) * 0x11)
126  );
127  return( true );
128 
129  default:
130  return( false ); // unrecognized
131  }
132  }
133 
134  return( false );
135 }
136 
137 //---------------------------------------------------------
138 CSG_String SG_Color_To_Text (long Color, bool bHexadecimal)
139 {
140  CSG_String Text;
141 
142  if( bHexadecimal )
143  {
144  Text.Printf("#%02X%02X%02X",
145  SG_GET_R(Color),
146  SG_GET_G(Color),
147  SG_GET_B(Color)
148  );
149  }
150  else
151  {
152  Text.Printf("%ld", Color);
153  }
154 
155  return( Text );
156 }
157 
158 
160 // //
161 // //
162 // //
164 
165 //---------------------------------------------------------
167 {
168  m_Colors = NULL;
169  m_nColors = 0;
170 
171  Create();
172 }
173 
174 //---------------------------------------------------------
176 {
177  m_Colors = NULL;
178  m_nColors = 0;
179 
180  Create(Colors);
181 }
182 
183 //---------------------------------------------------------
184 CSG_Colors::CSG_Colors(int nColors, int Palette, bool bRevert)
185 {
186  m_Colors = NULL;
187  m_nColors = 0;
188 
189  Create(nColors, Palette, bRevert);
190 }
191 
192 //---------------------------------------------------------
194 {
195  Destroy();
196 }
197 
198 
200 // //
202 
203 //---------------------------------------------------------
205 {
206  return( Create(11) );
207 }
208 
209 //---------------------------------------------------------
210 bool CSG_Colors::Create(const CSG_Colors &Colors)
211 {
212  if( Colors.m_nColors > 0 )
213  {
214  m_nColors = Colors.m_nColors;
215  m_Colors = (long *)SG_Realloc(m_Colors, m_nColors * sizeof(long));
216 
217  memcpy(m_Colors, Colors.m_Colors, m_nColors * sizeof(long));
218 
219  return( true );
220  }
221 
222  return( false );
223 }
224 
225 //---------------------------------------------------------
226 bool CSG_Colors::Create(int nColors, int Palette, bool bRevert)
227 {
228  if( nColors <= 1 )
229  {
230  nColors = 11;
231  }
232 
233  Set_Count(nColors);
234 
235  Set_Palette(Palette, bRevert, nColors);
236 
237  return( true );
238 }
239 
240 //---------------------------------------------------------
242 {
243  if( m_nColors > 0 )
244  {
245  SG_Free(m_Colors);
246 
247  m_Colors = NULL;
248  m_nColors = 0;
249  }
250 }
251 
252 
254 // //
256 
257 //---------------------------------------------------------
258 bool CSG_Colors::Set_Count(int nColors)
259 {
260  if( nColors == m_nColors )
261  {
262  return( true );
263  }
264 
265  if( nColors < 1 )
266  {
267  return( false );
268  }
269 
270  if( m_nColors == 0 )
271  {
272  return( Set_Default(nColors) );
273  }
274 
275  //-----------------------------------------------------
276  CSG_Colors Colors(*this);
277 
278  m_nColors = nColors;
279  m_Colors = (long *)SG_Realloc(m_Colors, m_nColors * sizeof(long));
280 
281  double dStep = Get_Count() > 1 ? (Colors.Get_Count() - 1.0) / (Get_Count() - 1.0) : 0.0;
282 
283  for(int i=0; i<Get_Count(); i++)
284  {
285  if( Get_Count() < Colors.Get_Count() )
286  {
287  m_Colors[i] = Colors[(int)(i * dStep)];
288  }
289  else // if( Get_Count() > Colors.Get_Count() )
290  {
291  m_Colors[i] = Colors.Get_Interpolated(i * dStep);
292  }
293  }
294 
295  //---------------------------------------------
296  return( true );
297 }
298 
299 
301 // //
303 
304 //---------------------------------------------------------
305 bool CSG_Colors::Set_Color(int Index, long Color)
306 {
307  if( Index >= 0 && Index < m_nColors )
308  {
309  m_Colors[Index] = Color;
310 
311  return( true );
312  }
313 
314  return( false );
315 }
316 
317 //---------------------------------------------------------
318 bool CSG_Colors::Set_Color(int Index, int Red, int Green, int Blue)
319 {
320  return( Set_Color(Index, SG_GET_RGB(Red, Green, Blue)) );
321 }
322 
323 //---------------------------------------------------------
324 bool CSG_Colors::Set_Red(int Index, int Value)
325 {
326  return( Set_Color(Index, Value , Get_Green(Index) , Get_Blue(Index)) );
327 }
328 
329 //---------------------------------------------------------
330 bool CSG_Colors::Set_Green(int Index, int Value)
331 {
332  return( Set_Color(Index, Get_Red(Index) , Value , Get_Blue(Index)) );
333 }
334 
335 //---------------------------------------------------------
336 bool CSG_Colors::Set_Blue(int Index, int Value)
337 {
338  return( Set_Color(Index, Get_Red(Index) , Get_Green(Index) , Value) );
339 }
340 
341 //---------------------------------------------------------
342 bool CSG_Colors::Set_Brightness(int Index, int Value)
343 {
344  double r, g, b, ds;
345 
346  //-----------------------------------------------------
347  if( Value < 0 )
348  {
349  Value = 0;
350  }
351  else if( Value > 255 )
352  {
353  Value = 255;
354  }
355 
356  //-----------------------------------------------------
357  r = Get_Red (Index);
358  g = Get_Green(Index);
359  b = Get_Blue (Index);
360  ds = (r + g + b) / 3.0;
361 
362  if( ds > 0.0 )
363  {
364  ds = Value / ds;
365  r *= ds;
366  g *= ds;
367  b *= ds;
368 
369  _Set_Brightness(r, g, b);
370  }
371  else
372  {
373  r = g = b = Value / 3.0;
374  }
375 
376  return( Set_Color(Index, (int)r, (int)g, (int)b) );
377 }
378 
379 //---------------------------------------------------------
380 void CSG_Colors::_Set_Brightness(double &a, double &b, double &c, int Pass)
381 {
382  if( a > 255 )
383  {
384  int addSum;
385 
386  addSum = (int)((a - 255) / 2.0);
387  a = 255;
388 
389  b += addSum;
390  c += addSum;
391 
392  if( b > 255 )
393  {
394  addSum = (int)(b - 255);
395  b = 255;
396 
397  c += addSum;
398 
399  if( c > 255 )
400  {
401  c = 255;
402  }
403  }
404  else if( c > 255 )
405  {
406  addSum = (int)(c - 255);
407  c = 255;
408 
409  b += addSum;
410 
411  if( b > 255 )
412  {
413  b = 255;
414  }
415  }
416  }
417  else if( Pass < 2 )
418  {
419  _Set_Brightness(b, c, a, Pass + 1);
420  }
421 }
422 
423 
425 // //
427 
428 //---------------------------------------------------------
430 {
431  return( SG_COLORS_COUNT );
432 }
433 
434 //---------------------------------------------------------
436 {
437  switch( Index )
438  {
439  case SG_COLORS_DEFAULT : return( _TL("default" ) );
440  case SG_COLORS_DEFAULT_BRIGHT : return( _TL("default (same brightness)") );
441  case SG_COLORS_BLACK_WHITE : return( _TL("greyscale" ) );
442  case SG_COLORS_BLACK_RED : return( _TL("black > red" ) );
443  case SG_COLORS_BLACK_GREEN : return( _TL("black > green" ) );
444  case SG_COLORS_BLACK_BLUE : return( _TL("black > blue" ) );
445  case SG_COLORS_WHITE_RED : return( _TL("white > red" ) );
446  case SG_COLORS_WHITE_GREEN : return( _TL("white > green" ) );
447  case SG_COLORS_WHITE_BLUE : return( _TL("white > blue" ) );
448  case SG_COLORS_YELLOW_RED : return( _TL("yellow > red" ) );
449  case SG_COLORS_YELLOW_GREEN : return( _TL("yellow > green" ) );
450  case SG_COLORS_YELLOW_BLUE : return( _TL("yellow > blue" ) );
451  case SG_COLORS_GREEN_RED : return( _TL("green > red" ) );
452  case SG_COLORS_RED_GREEN : return( _TL("red > green" ) );
453  case SG_COLORS_RED_BLUE : return( _TL("red > blue" ) );
454  case SG_COLORS_GREEN_BLUE : return( _TL("green > blue" ) );
455  case SG_COLORS_RED_GREY_BLUE : return( _TL("red > grey > blue" ) );
456  case SG_COLORS_RED_GREY_GREEN : return( _TL("red > grey > green" ) );
457  case SG_COLORS_GREEN_GREY_BLUE: return( _TL("green > grey > blue" ) );
458  case SG_COLORS_RED_GREEN_BLUE : return( _TL("red > green > blue" ) );
459  case SG_COLORS_RED_BLUE_GREEN : return( _TL("red > blue > green" ) );
460  case SG_COLORS_GREEN_RED_BLUE : return( _TL("green > red > blue" ) );
461  case SG_COLORS_RAINBOW : return( _TL("rainbow" ) );
462  case SG_COLORS_NEON : return( _TL("neon" ) );
463  case SG_COLORS_TOPOGRAPHY : return( _TL("topography 1" ) );
464  case SG_COLORS_TOPOGRAPHY_2 : return( _TL("topography 2" ) );
465  case SG_COLORS_TOPOGRAPHY_3 : return( _TL("topography 3" ) );
466  case SG_COLORS_PRECIPITATION : return( _TL("precipitation" ) );
467  case SG_COLORS_ASPECT_1 : return( _TL("aspect 1" ) );
468  case SG_COLORS_ASPECT_2 : return( _TL("aspect 2" ) );
469  case SG_COLORS_ASPECT_3 : return( _TL("aspect 3" ) );
470  default : return( _TL("" ) );
471  }
472 }
473 
474 //---------------------------------------------------------
475 bool CSG_Colors::Set_Predefined(int Index, bool bRevert, int nColors)
476 {
477  switch( Index )
478  {
479  case SG_COLORS_DEFAULT:
480  Set_Default(nColors);
481  break;
482 
484  Set_Default(nColors);
485  Set_Ramp_Brighness(127, 127);
486  break;
487 
489  Set_Ramp(SG_GET_RGB( 0, 0, 0), SG_GET_RGB(255, 255, 255));
490  break;
491 
492  case SG_COLORS_BLACK_RED:
493  Set_Ramp(SG_GET_RGB( 0, 0, 0), SG_GET_RGB(255, 0, 0));
494  break;
495 
497  Set_Ramp(SG_GET_RGB( 0, 0, 0), SG_GET_RGB( 0, 255, 0));
498  break;
499 
501  Set_Ramp(SG_GET_RGB( 0, 0, 0), SG_GET_RGB( 0, 0, 255));
502  break;
503 
504  case SG_COLORS_WHITE_RED:
505  Set_Count(3);
506  Set_Color(0, SG_GET_RGB(255, 255, 255));
507  Set_Color(1, SG_GET_RGB(255, 127, 0));
508  Set_Color(2, SG_GET_RGB(159, 0, 0));
509  break;
510 
512  Set_Ramp(SG_GET_RGB(255, 255, 255), SG_GET_RGB( 0, 127, 0));
513  break;
514 
516  Set_Count(3);
517  Set_Color(0, SG_GET_RGB(255, 255, 255));
518  Set_Color(1, SG_GET_RGB( 0, 127, 255));
519  Set_Color(2, SG_GET_RGB( 0, 0, 159));
520  break;
521 
523  Set_Count(3);
524  Set_Color(0, SG_GET_RGB(255, 255, 127));
525  Set_Color(1, SG_GET_RGB(255, 127, 0));
526  Set_Color(2, SG_GET_RGB(127, 0, 0));
527  break;
528 
530  Set_Count(3);
531  Set_Color(0, SG_GET_RGB(255, 255, 127));
532  Set_Color(1, SG_GET_RGB(127, 255, 0));
533  Set_Color(2, SG_GET_RGB( 0, 127, 0));
534  break;
535 
537  Set_Count(3);
538  Set_Color(0, SG_GET_RGB(255, 255, 200));
539  Set_Color(1, SG_GET_RGB(127, 192, 255));
540  Set_Color(2, SG_GET_RGB( 0, 64, 127));
541  break;
542 
543  case SG_COLORS_GREEN_RED:
544  Set_Count(3);
545  Set_Color(0, SG_GET_RGB( 0, 127, 0));
546  Set_Color(1, SG_GET_RGB(255, 255, 0));
547  Set_Color(2, SG_GET_RGB(255, 0, 0));
548  break;
549 
550  case SG_COLORS_RED_GREEN:
551  Set_Count(3);
552  Set_Color(0, SG_GET_RGB(200, 0, 0));
553  Set_Color(1, SG_GET_RGB(255, 255, 127));
554  Set_Color(2, SG_GET_RGB( 0, 63, 0));
555  break;
556 
557  case SG_COLORS_RED_BLUE:
558  Set_Ramp(SG_GET_RGB(255, 0, 0), SG_GET_RGB( 0, 0, 255));
559  break;
560 
562  Set_Ramp(SG_GET_RGB( 0, 255, 0), SG_GET_RGB( 0, 0, 255));
563  break;
564 
566  Set_Count(5);
567  Set_Color(0, SG_GET_RGB(127, 0, 0));
568  Set_Color(1, SG_GET_RGB(255, 127, 0));
569  Set_Color(2, SG_GET_RGB(239, 239, 239));
570  Set_Color(3, SG_GET_RGB( 0, 127, 255));
571  Set_Color(4, SG_GET_RGB( 0, 0, 127));
572  break;
573 
575  Set_Count(5);
576  Set_Color(0, SG_GET_RGB(127, 0, 0));
577  Set_Color(1, SG_GET_RGB(255, 127, 0));
578  Set_Color(2, SG_GET_RGB(239, 239, 239));
579  Set_Color(3, SG_GET_RGB( 0, 255, 127));
580  Set_Color(4, SG_GET_RGB( 0, 127, 0));
581  break;
582 
584  Set_Count(5);
585  Set_Color(0, SG_GET_RGB( 0, 127, 0));
586  Set_Color(1, SG_GET_RGB(127, 255, 0));
587  Set_Color(2, SG_GET_RGB(239, 239, 239));
588  Set_Color(3, SG_GET_RGB( 0, 127, 255));
589  Set_Color(4, SG_GET_RGB( 0, 0, 127));
590  break;
591 
593  Set_Count(5);
594  Set_Color(0, SG_GET_RGB(127, 0, 127));
595  Set_Color(1, SG_GET_RGB(255, 0, 0));
596  Set_Color(2, SG_GET_RGB( 0, 255, 0));
597  Set_Color(3, SG_GET_RGB( 0, 0, 255));
598  Set_Color(4, SG_GET_RGB(127, 0, 127));
599  break;
600 
602  Set_Count(5);
603  Set_Color(0, SG_GET_RGB(127, 127, 0));
604  Set_Color(1, SG_GET_RGB(255, 0, 0));
605  Set_Color(2, SG_GET_RGB( 0, 0, 255));
606  Set_Color(3, SG_GET_RGB( 0, 255, 0));
607  Set_Color(4, SG_GET_RGB(127, 127, 0));
608  break;
609 
611  Set_Count(5);
612  Set_Color(0, SG_GET_RGB( 0, 127, 127));
613  Set_Color(1, SG_GET_RGB( 0, 255, 0));
614  Set_Color(2, SG_GET_RGB(255, 0, 0));
615  Set_Color(3, SG_GET_RGB( 0, 0, 255));
616  Set_Color(4, SG_GET_RGB( 0, 127, 127));
617  break;
618 
619  case SG_COLORS_RAINBOW:
620  Set_Count(8);
621  Set_Color(0, SG_GET_RGB( 64, 0, 127));
622  Set_Color(1, SG_GET_RGB( 0, 0, 255));
623  Set_Color(2, SG_GET_RGB( 0, 255, 255));
624  Set_Color(3, SG_GET_RGB( 0, 191, 0));
625  Set_Color(4, SG_GET_RGB(255, 255, 0));
626  Set_Color(5, SG_GET_RGB(255, 127, 0));
627  Set_Color(6, SG_GET_RGB(255, 0, 0));
628  Set_Color(7, SG_GET_RGB(127, 0, 0));
629  break;
630 
631  case SG_COLORS_NEON:
632  Set_Count(7);
633  Set_Color(0, SG_GET_RGB( 0, 0, 0));
634  Set_Color(1, SG_GET_RGB(255, 0, 0));
635  Set_Color(2, SG_GET_RGB( 0, 0, 0));
636  Set_Color(3, SG_GET_RGB(255, 255, 0));
637  Set_Color(4, SG_GET_RGB( 0, 0, 0));
638  Set_Color(5, SG_GET_RGB( 0, 255, 0));
639  Set_Color(6, SG_GET_RGB( 0, 0, 0));
640  break;
641 
643  Set_Count(5);
644  Set_Color(0, SG_GET_RGB( 0, 63, 127));
645  Set_Color(1, SG_GET_RGB(127, 255, 0));
646  Set_Color(2, SG_GET_RGB(255, 255, 127));
647  Set_Color(3, SG_GET_RGB(191, 127, 0));
648  Set_Color(4, SG_GET_RGB(127, 63, 0));
649  break;
650 
652  Set_Count(6);
653  Set_Color(0, SG_GET_RGB( 0, 191, 191));
654  Set_Color(1, SG_GET_RGB( 0, 255, 0));
655  Set_Color(2, SG_GET_RGB(255, 255, 0));
656  Set_Color(3, SG_GET_RGB(255, 127, 0));
657  Set_Color(4, SG_GET_RGB(191, 152, 110));
658  Set_Color(5, SG_GET_RGB(199, 199, 199));
659  break;
660 
662  Set_Count(9);
663  Set_Color(0, SG_GET_RGB(177, 242, 212));
664  Set_Color(1, SG_GET_RGB(248, 252, 179));
665  Set_Color(2, SG_GET_RGB( 11, 128, 064));
666  Set_Color(3, SG_GET_RGB(248, 202, 80));
667  Set_Color(4, SG_GET_RGB(158, 30, 0));
668  Set_Color(5, SG_GET_RGB(128, 064, 064));
669  Set_Color(6, SG_GET_RGB(185, 121, 076));
670  Set_Color(7, SG_GET_RGB(179, 179, 179));
671  Set_Color(8, SG_GET_RGB(255, 255, 255));
672  break;
673 
674  case SG_COLORS_PRECIPITATION: // juergen's favorite precipition colour ramp
675  Set_Count(22);
676  Set_Color( 0, SG_GET_RGB(216, 204, 131));
677  Set_Color( 1, SG_GET_RGB(196, 208, 111));
678  Set_Color( 2, SG_GET_RGB(184, 210, 101));
679  Set_Color( 3, SG_GET_RGB(172, 212, 91));
680  Set_Color( 4, SG_GET_RGB(139, 212, 99));
681  Set_Color( 5, SG_GET_RGB(107, 212, 107));
682  Set_Color( 6, SG_GET_RGB( 75, 212, 119));
683  Set_Color( 7, SG_GET_RGB( 42, 212, 131));
684  Set_Color( 8, SG_GET_RGB( 26, 212, 151));
685  Set_Color( 9, SG_GET_RGB( 10, 212, 172));
686  Set_Color(10, SG_GET_RGB( 30, 192, 192));
687  Set_Color(11, SG_GET_RGB( 50, 172, 212));
688  Set_Color(12, SG_GET_RGB( 70, 151, 214));
689  Set_Color(13, SG_GET_RGB( 91, 131, 216));
690  Set_Color(14, SG_GET_RGB( 75, 115, 198));
691  Set_Color(15, SG_GET_RGB( 58, 99, 180));
692  Set_Color(16, SG_GET_RGB( 42, 83, 184));
693  Set_Color(17, SG_GET_RGB( 26, 066, 188));
694  Set_Color(18, SG_GET_RGB( 26, 046, 180));
695  Set_Color(19, SG_GET_RGB( 26, 026, 166));
696  Set_Color(20, SG_GET_RGB( 38, 18, 151));
697  Set_Color(21, SG_GET_RGB( 50, 010, 131));
698  break;
699 
700  case SG_COLORS_ASPECT_1:
701  Set_Count(5);
702  Set_Color(0, SG_GET_RGB(225, 225, 225));
703  Set_Color(1, SG_GET_RGB(127, 127, 255));
704  Set_Color(2, SG_GET_RGB( 20, 20, 20));
705  Set_Color(3, SG_GET_RGB(127, 255, 127));
706  Set_Color(4, SG_GET_RGB(225, 225, 225));
707  break;
708 
709  case SG_COLORS_ASPECT_2:
710  Set_Count(5);
711  Set_Color(0, SG_GET_RGB(225, 225, 225));
712  Set_Color(1, SG_GET_RGB(255, 127, 127));
713  Set_Color(2, SG_GET_RGB( 20, 20, 20));
714  Set_Color(3, SG_GET_RGB(127, 255, 127));
715  Set_Color(4, SG_GET_RGB(225, 225, 225));
716  break;
717 
718  case SG_COLORS_ASPECT_3:
719  Set_Count(5);
720  Set_Color(0, SG_GET_RGB(225, 225, 225));
721  Set_Color(1, SG_GET_RGB(255, 127, 127));
722  Set_Color(2, SG_GET_RGB( 20, 20, 20));
723  Set_Color(3, SG_GET_RGB(127, 127, 255));
724  Set_Color(4, SG_GET_RGB(225, 225, 225));
725  break;
726 
727  case SG_COLORS_COUNT + 0:
728  Set_Count(3);
729  Set_Color(0, SG_GET_RGB( 0, 128, 0));
730  Set_Color(1, SG_GET_RGB(255, 255, 127));
731  Set_Color(2, SG_GET_RGB(127, 63, 63));
732  break;
733 
734  case SG_COLORS_COUNT + 1:
735  Set_Count(3);
736  Set_Color(0, SG_GET_RGB( 0, 0, 255));
737  Set_Color(1, SG_GET_RGB(255, 255, 0));
738  Set_Color(2, SG_GET_RGB(255, 0, 0));
739  break;
740 
741  case SG_COLORS_COUNT + 2:
742  Set_Count(3);
743  Set_Color(0, SG_GET_RGB( 0, 127, 0));
744  Set_Color(1, SG_GET_RGB(255, 255, 255));
745  Set_Color(2, SG_GET_RGB(255, 0, 0));
746  break;
747 
748  case SG_COLORS_COUNT + 3:
749  Set_Count(3);
750  Set_Color(0, SG_GET_RGB( 0, 0, 255));
751  Set_Color(1, SG_GET_RGB(255, 255, 255));
752  Set_Color(2, SG_GET_RGB( 0, 127, 0));
753  break;
754 
755  case SG_COLORS_COUNT + 4:
756  Set_Count(4);
757  Set_Color(0, SG_GET_RGB( 0, 0, 255));
758  Set_Color(1, SG_GET_RGB( 0, 255, 0));
759  Set_Color(2, SG_GET_RGB(255, 255, 0));
760  Set_Color(3, SG_GET_RGB(255, 0, 0));
761  break;
762 
763  case SG_COLORS_COUNT + 5:
764  Set_Count(11);
765  Set_Color( 0, SG_GET_RGB( 37, 57, 175));
766  Set_Color( 1, SG_GET_RGB( 40, 127, 251));
767  Set_Color( 2, SG_GET_RGB( 50, 190, 255));
768  Set_Color( 3, SG_GET_RGB(106, 235, 255));
769  Set_Color( 4, SG_GET_RGB(138, 236, 174));
770  Set_Color( 5, SG_GET_RGB(205, 255, 162));
771  Set_Color( 6, SG_GET_RGB(240, 236, 121));
772  Set_Color( 7, SG_GET_RGB(255, 189, 87));
773  Set_Color( 8, SG_GET_RGB(255, 161, 68));
774  Set_Color( 9, SG_GET_RGB(255, 186, 133));
775  Set_Color(10, SG_GET_RGB(255, 255, 255));
776  break;
777 
778  case SG_COLORS_COUNT + 6:
779  Set_Count(8);
780  Set_Color(0, SG_GET_RGB(171, 43, 0));
781  Set_Color(1, SG_GET_RGB(255, 127, 0));
782  Set_Color(2, SG_GET_RGB(255, 255, 0));
783  Set_Color(3, SG_GET_RGB( 0, 255, 0));
784  Set_Color(4, SG_GET_RGB( 0, 255, 255));
785  Set_Color(5, SG_GET_RGB( 0, 0, 255));
786  Set_Color(6, SG_GET_RGB(255, 0, 255));
787  Set_Color(7, SG_GET_RGB(255, 255, 255));
788  break;
789 
790  case SG_COLORS_COUNT + 7:
791  Set_Count(5);
792  Set_Color(0, SG_GET_RGB( 0, 0, 191));
793  Set_Color(1, SG_GET_RGB(255, 0, 255));
794  Set_Color(2, SG_GET_RGB(255, 0, 0));
795  Set_Color(3, SG_GET_RGB(255, 255, 0));
796  Set_Color(4, SG_GET_RGB(245, 245, 163));
797  break;
798 
799  case SG_COLORS_COUNT + 8:
800  Set_Count(6);
801  Set_Color(0, SG_GET_RGB(127, 255, 255));
802  Set_Color(1, SG_GET_RGB( 0, 0, 255));
803  Set_Color(2, SG_GET_RGB(127, 0, 255));
804  Set_Color(3, SG_GET_RGB(255, 0, 0));
805  Set_Color(4, SG_GET_RGB(255, 255, 0));
806  Set_Color(5, SG_GET_RGB(255, 255, 127));
807  break;
808 
809  case SG_COLORS_COUNT + 9:
810  Set_Count(5);
811  Set_Color(0, SG_GET_RGB( 0, 0, 127));
812  Set_Color(1, SG_GET_RGB( 0, 127, 255));
813  Set_Color(2, SG_GET_RGB( 0, 191, 0));
814  Set_Color(3, SG_GET_RGB(191, 255, 0));
815  Set_Color(4, SG_GET_RGB(255, 255, 127));
816  break;
817 
818  case SG_COLORS_COUNT + 10:
819  Set_Count(nColors);
820  Random();
821  break;
822 
823  default:
824  return( false );
825  }
826 
827  //-----------------------------------------------------
828  if( bRevert )
829  {
830  Revert();
831  }
832 
833  return( Set_Count(nColors) );
834 }
835 
836 //---------------------------------------------------------
837 bool CSG_Colors::Set_Default(int nColors)
838 {
839  if( nColors > 0 )
840  {
841  m_nColors = nColors;
842  m_Colors = (long *)SG_Realloc(m_Colors, m_nColors * sizeof(long));
843 
844  double d = 0., dStep = 2. * M_PI / (double)Get_Count();
845 
846  for(int i=0; i<Get_Count(); i++, d+=dStep)
847  {
848  Set_Color(i,
849  (int)(d < M_PI / 2 ? 0 : 128 - 127 * sin(M_PI - d)),
850  (int)(128 - 127 * cos(d)),
851  (int)(d > M_PI * 3 / 2 ? 0 : 128 + 127 * sin(d))
852  );
853  }
854 
855  return( true );
856  }
857 
858  return( false );
859 }
860 
861 //---------------------------------------------------------
862 bool CSG_Colors::Set_Ramp(long Color_A, long Color_B)
863 {
864  return( Set_Ramp(Color_A, Color_B, 0, Get_Count() - 1) );
865 }
866 
867 //---------------------------------------------------------
868 bool CSG_Colors::Set_Ramp(long Color_A, long Color_B, int iColor_A, int iColor_B)
869 {
870  if( iColor_A > iColor_B )
871  {
872  int i = iColor_A;
873  iColor_A = iColor_B;
874  iColor_B = i;
875  }
876 
877  if( iColor_A < 0 )
878  {
879  iColor_A = 0;
880  }
881 
882  if( iColor_B >= Get_Count() )
883  {
884  iColor_B = Get_Count() - 1;
885  }
886 
887  //-----------------------------------------------------
888  int n = iColor_B - iColor_A;
889 
890  if( n > 0 )
891  {
892  int ar = SG_GET_R(Color_A);
893  double dr = (double)(SG_GET_R(Color_B) - ar) / (double)n;
894 
895  int ag = SG_GET_G(Color_A);
896  double dg = (double)(SG_GET_G(Color_B) - ag) / (double)n;
897 
898  int ab = SG_GET_B(Color_A);
899  double db = (double)(SG_GET_B(Color_B) - ab) / (double)n;
900 
901  for(int i=0; i<=n; i++)
902  {
903  Set_Color(iColor_A + i,
904  (int)(ar + i * dr),
905  (int)(ag + i * dg),
906  (int)(ab + i * db)
907  );
908  }
909 
910  return( true );
911  }
912 
913  return( false );
914 }
915 
916 //---------------------------------------------------------
917 bool CSG_Colors::Set_Ramp_Brighness(int Brightness_A, int Brightness_B)
918 {
919  return( Set_Ramp_Brighness(Brightness_A, Brightness_B, 0, Get_Count() - 1) );
920 }
921 
922 //---------------------------------------------------------
923 bool CSG_Colors::Set_Ramp_Brighness(int Brightness_A, int Brightness_B, int iColor_A, int iColor_B)
924 {
925  if( iColor_A > iColor_B )
926  {
927  int i = iColor_A;
928  iColor_A = iColor_B;
929  iColor_B = i;
930  }
931 
932  if( iColor_A < 0 )
933  {
934  iColor_A = 0;
935  }
936 
937  if( iColor_B >= Get_Count() )
938  {
939  iColor_B = Get_Count() - 1;
940  }
941 
942  //-----------------------------------------------------
943  int n = iColor_B - iColor_A;
944 
945  if( n > 0 )
946  {
947  double dBrightness = (double)(Brightness_B - Brightness_A) / (double)n;
948 
949  for(int i=0; i<=n; i++)
950  {
951  Set_Brightness(iColor_A + i, (int)(Brightness_A + i * dBrightness));
952  }
953 
954  return( true );
955  }
956 
957  return( false );
958 }
959 
960 
962 // //
964 
965 //---------------------------------------------------------
967 {
968  for(int i=0; i<Get_Count(); i++)
969  {
970  Set_Color(i,
971  (int)(255.0 * (double)rand() / (double)RAND_MAX),
972  (int)(255.0 * (double)rand() / (double)RAND_MAX),
973  (int)(255.0 * (double)rand() / (double)RAND_MAX)
974  );
975  }
976 
977  return( Get_Count() > 0 );
978 }
979 
980 //---------------------------------------------------------
982 {
983  for(int i=0; i<Get_Count(); i++)
984  {
985  Set_Color(i, 255 - Get_Red(i), 255 - Get_Green(i), 255 - Get_Blue(i));
986  }
987 
988  return( Get_Count() > 0 );
989 }
990 
991 //---------------------------------------------------------
993 {
994  for(int i=0, j=Get_Count()-1; i<j; i++, j--)
995  {
996  long c = Get_Color(j);
997  Set_Color(j, Get_Color(i));
998  Set_Color(i, c);
999  }
1000 
1001  return( Get_Count() > 0 );
1002 }
1003 
1004 //---------------------------------------------------------
1006 {
1007  for(int i=0; i<Get_Count(); i++)
1008  {
1009  long c = Get_Brightness(i);
1010 
1011  Set_Color(i, c, c, c);
1012  }
1013 
1014  return( Get_Count() > 0 );
1015 }
1016 
1017 
1019 // //
1021 
1022 //---------------------------------------------------------
1024 {
1025  Create(Colors);
1026 
1027  return( *this );
1028 }
1029 
1030 //---------------------------------------------------------
1031 bool CSG_Colors::Assign(const CSG_Colors &Colors)
1032 {
1033  return( Create(Colors) );
1034 }
1035 
1036 //---------------------------------------------------------
1038 {
1039  return( pColors ? Create(*pColors) : false );
1040 }
1041 
1042 
1044 // //
1046 
1047 //---------------------------------------------------------
1048 #define COLORS_SERIAL_VERSION_BINARY "SAGA_COLORPALETTE_VERSION_0.100_BINARY"
1049 #define COLORS_SERIAL_VERSION__ASCII "SAGA_COLORPALETTE_VERSION_0.100__ASCII"
1050 
1051 //---------------------------------------------------------
1052 bool CSG_Colors::Load(const CSG_String &File_Name)
1053 {
1054  CSG_File Stream;
1055 
1056  if( !Stream.Open(File_Name, SG_FILE_R, true) )
1057  {
1058  return( false );
1059  }
1060 
1061  CSG_String Version;
1062 
1063  Stream.Read(Version, sizeof(COLORS_SERIAL_VERSION__ASCII));
1064 
1065  //-----------------------------------------------------
1066  if( Version.Find(COLORS_SERIAL_VERSION__ASCII) == 0 )
1067  {
1068  return( Serialize(Stream, false, false) );
1069  }
1070 
1071  //-----------------------------------------------------
1072  Stream.Seek_Start();
1073  Stream.Read(Version, sizeof(COLORS_SERIAL_VERSION_BINARY));
1074 
1075  if( Version.Find(COLORS_SERIAL_VERSION_BINARY) == 0 )
1076  {
1077  int nColors;
1078 
1079  Stream.Read(&nColors, sizeof(nColors));
1080 
1081  if( Set_Count(nColors) ) // different os, different sizeof(long) !!
1082  {
1083  size_t ValueSize = (size_t)((Stream.Length() - (sizeof(COLORS_SERIAL_VERSION_BINARY) + sizeof(int))) / nColors);
1084 
1085  if( ValueSize > 0 )
1086  {
1087  BYTE *c = (BYTE *)SG_Malloc(ValueSize);
1088 
1089  for(int i=0; i<nColors; i++)
1090  {
1091  Stream.Read(c, ValueSize);
1092 
1093  Set_Color(i, c[0], c[1], c[2]);
1094  }
1095 
1096  SG_Free(c);
1097  }
1098 
1099  return( true );
1100  }
1101  }
1102 
1103  //-----------------------------------------------------
1104  else // SAGA 1.x compatibility...
1105  {
1106  short nColors;
1107 
1108  Stream.Seek_Start();
1109  Stream.Read(&nColors, sizeof(short));
1110 
1111  if( Stream.Length() == (int)(sizeof(short) + 3 * nColors) && Set_Count(nColors) )
1112  {
1113  BYTE *R = (BYTE *)SG_Malloc(nColors * sizeof(BYTE)); Stream.Read(R, nColors * sizeof(BYTE));
1114  BYTE *G = (BYTE *)SG_Malloc(nColors * sizeof(BYTE)); Stream.Read(G, nColors * sizeof(BYTE));
1115  BYTE *B = (BYTE *)SG_Malloc(nColors * sizeof(BYTE)); Stream.Read(B, nColors * sizeof(BYTE));
1116 
1117  for(int i=0; i<nColors; i++)
1118  {
1119  Set_Color(i, R[i], G[i], B[i]);
1120  }
1121 
1122  SG_Free(R); SG_Free(G); SG_Free(B);
1123 
1124  return( true );
1125  }
1126  }
1127 
1128  //-----------------------------------------------------
1129  return( false );
1130 }
1131 
1132 //---------------------------------------------------------
1133 bool CSG_Colors::Save(const CSG_String &File_Name, bool bBinary)
1134 {
1135  CSG_File Stream;
1136 
1137  if( Stream.Open(File_Name, SG_FILE_W, bBinary) )
1138  {
1139  if( bBinary )
1140  {
1142  }
1143  else
1144  {
1145  Stream.Write(COLORS_SERIAL_VERSION__ASCII); Stream.Write("\n");
1146  }
1147 
1148  Serialize(Stream, true, bBinary);
1149 
1150  return( true );
1151  }
1152 
1153  return( false );
1154 }
1155 
1156 
1158 // //
1160 
1161 //---------------------------------------------------------
1162 bool CSG_Colors::Serialize(CSG_File &Stream, bool bSave, bool bBinary)
1163 {
1164  if( Stream.is_Open() )
1165  {
1166  //-------------------------------------------------
1167  if( bBinary )
1168  {
1169  if( bSave )
1170  {
1171  if( m_nColors > 0 )
1172  {
1173  Stream.Write(&m_nColors, sizeof(m_nColors));
1174  Stream.Write(m_Colors, sizeof(long), m_nColors);
1175  }
1176  }
1177  else
1178  {
1179  int nColors;
1180 
1181  Stream.Read(&nColors, sizeof(m_nColors));
1182 
1183  if( Set_Count(nColors) )
1184  {
1185  Stream.Read(m_Colors, sizeof(long), m_nColors);
1186  }
1187  }
1188 
1189  return( true );
1190  }
1191 
1192  //-------------------------------------------------
1193  else
1194  {
1195  if( bSave )
1196  {
1197  if( Get_Count() > 0 )
1198  {
1199  Stream.Printf("%d\n", Get_Count());
1200 
1201  for(int i=0; i<Get_Count(); i++)
1202  {
1203  Stream.Printf("%03d %03d %03d\n", (int)Get_Red(i), (int)Get_Green(i), (int)Get_Blue(i));
1204  }
1205  }
1206  }
1207  else
1208  {
1209  CSG_String sLine;
1210 
1211  while( Stream.Read_Line(sLine) && sLine.is_Empty() ) {} // skip empty lines
1212 
1213  if( Set_Count(sLine.asInt()) )
1214  {
1215  for(int i=0; i<Get_Count(); i++)
1216  {
1217  Stream.Read_Line(sLine);
1218 
1219  Set_Color(i,
1220  sLine .asInt(),
1221  sLine.AfterFirst(' ').asInt(),
1222  sLine.AfterLast (' ').asInt()
1223  );
1224  }
1225  }
1226  }
1227 
1228  return( true );
1229  }
1230  }
1231 
1232  return( false );
1233 }
1234 
1235 //---------------------------------------------------------
1237 {
1238  if( Get_Count() > 0 )
1239  {
1240  String.Clear();
1241 
1242  for(int i=0; i<Get_Count(); i++)
1243  {
1244  String += CSG_String::Format("%03d %03d %03d;", (int)Get_Red(i), (int)Get_Green(i), (int)Get_Blue(i));
1245  }
1246 
1247  return( true );
1248  }
1249 
1250  return( false );
1251 }
1252 
1253 //---------------------------------------------------------
1255 {
1256  if( Set_Count((int)String.Length() / 12) )
1257  {
1258  for(int i=0, j=0; i<Get_Count(); i++, j+=12)
1259  {
1260  Set_Color(i,
1261  String.Mid(j + 0, 4).asInt(),
1262  String.Mid(j + 4, 4).asInt(),
1263  String.Mid(j + 8, 4).asInt()
1264  );
1265  }
1266 
1267  return( true );
1268  }
1269 
1270  return( false );
1271 }
1272 
1273 
1275 // //
1276 // //
1277 // //
1279 
1280 //---------------------------------------------------------
CSG_Colors::Set_Brightness
bool Set_Brightness(int Index, int Value)
Definition: api_colors.cpp:342
CSG_Colors::Set_Color
bool Set_Color(int Index, long Color)
Definition: api_colors.cpp:305
CSG_File::Open
virtual bool Open(const CSG_String &FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
Definition: api_file.cpp:111
CSG_Colors::from_Text
bool from_Text(const CSG_String &String)
Definition: api_colors.cpp:1254
SG_GET_RGB
#define SG_GET_RGB(r, g, b)
Definition: api_core.h:1253
SG_COLORS_RED_BLUE_GREEN
@ SG_COLORS_RED_BLUE_GREEN
Definition: api_core.h:1305
CSG_String::Printf
int Printf(const char *Format,...)
Definition: api_string.cpp:308
CSG_File::Seek_Start
bool Seek_Start(void) const
Definition: api_file.cpp:251
_TL
#define _TL(s)
Definition: api_core.h:1480
CSG_Colors::Greyscale
bool Greyscale(void)
Definition: api_colors.cpp:1005
SG_GET_B
#define SG_GET_B(rgb)
Definition: api_core.h:1258
CSG_String::Length
size_t Length(void) const
Definition: api_string.cpp:172
SG_Color_From_Text
bool SG_Color_From_Text(const CSG_String &Text, long &Color)
Definition: api_colors.cpp:79
SG_Colors_Get_Name
CSG_String SG_Colors_Get_Name(int Index)
Definition: api_colors.cpp:67
CSG_String::b_str
const char * b_str(void) const
Definition: api_string.cpp:242
CSG_Colors::Load
bool Load(const CSG_String &File_Name)
Definition: api_colors.cpp:1052
SG_COLORS_GREEN_BLUE
@ SG_COLORS_GREEN_BLUE
Definition: api_core.h:1300
CSG_Colors::Revert
bool Revert(void)
Definition: api_colors.cpp:992
CSG_String::Mid
CSG_String Mid(size_t first, size_t count=0) const
Definition: api_string.cpp:699
SG_COLORS_RED_GREY_BLUE
@ SG_COLORS_RED_GREY_BLUE
Definition: api_core.h:1301
CSG_Colors::Get_Predefined_Name
static CSG_String Get_Predefined_Name(int Identifier)
Definition: api_colors.cpp:435
CSG_Colors::Get_Blue
long Get_Blue(int Index) const
Definition: api_core.h:1360
CSG_Colors::Destroy
void Destroy(void)
Definition: api_colors.cpp:241
CSG_String::asInt
int asInt(void) const
Definition: api_string.cpp:722
SG_COLORS_BLACK_BLUE
@ SG_COLORS_BLACK_BLUE
Definition: api_core.h:1290
CSG_Random::Get_Uniform
static double Get_Uniform(void)
Definition: mat_tools.cpp:274
SG_Malloc
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
Definition: api_memory.cpp:65
CSG_Colors::Invert
bool Invert(void)
Definition: api_colors.cpp:981
SG_Color_Get_Random
long SG_Color_Get_Random(void)
Definition: api_colors.cpp:73
SG_COLORS_TOPOGRAPHY
@ SG_COLORS_TOPOGRAPHY
Definition: api_core.h:1309
CSG_String::Get_Char
SG_Char Get_Char(size_t i) const
Definition: api_string.cpp:209
api_core.h
SG_COLORS_WHITE_GREEN
@ SG_COLORS_WHITE_GREEN
Definition: api_core.h:1292
SG_COLORS_RAINBOW
@ SG_COLORS_RAINBOW
Definition: api_core.h:1307
SG_COLORS_BLACK_RED
@ SG_COLORS_BLACK_RED
Definition: api_core.h:1288
SG_Free
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
Definition: api_memory.cpp:83
SG_FILE_R
@ SG_FILE_R
Definition: api_core.h:1101
CSG_Colors::Set_Blue
bool Set_Blue(int Index, int Value)
Definition: api_colors.cpp:336
CSG_Colors::Get_Red
long Get_Red(int Index) const
Definition: api_core.h:1358
SG_COLORS_ASPECT_2
@ SG_COLORS_ASPECT_2
Definition: api_core.h:1314
CSG_File::Read
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
Definition: api_file.cpp:322
CSG_Colors::Set_Ramp
bool Set_Ramp(long Color_A, long Color_B)
Definition: api_colors.cpp:862
CSG_File
Definition: api_core.h:1116
SG_GET_R
#define SG_GET_R(rgb)
Definition: api_core.h:1256
SG_COLORS_NEON
@ SG_COLORS_NEON
Definition: api_core.h:1308
mat_tools.h
CSG_Colors::Get_Predefined_Count
static int Get_Predefined_Count(void)
Definition: api_colors.cpp:429
CSG_Colors::Set_Predefined
bool Set_Predefined(int Index, bool bRevert=false, int nColors=11)
Definition: api_colors.cpp:475
COLORS_SERIAL_VERSION__ASCII
#define COLORS_SERIAL_VERSION__ASCII
Definition: api_colors.cpp:1049
SG_COLORS_YELLOW_BLUE
@ SG_COLORS_YELLOW_BLUE
Definition: api_core.h:1296
SG_COLORS_BLACK_WHITE
@ SG_COLORS_BLACK_WHITE
Definition: api_core.h:1287
SG_COLORS_YELLOW_RED
@ SG_COLORS_YELLOW_RED
Definition: api_core.h:1294
CSG_Colors::Get_Count
int Get_Count(void) const
Definition: api_core.h:1345
SG_COLORS_YELLOW_GREEN
@ SG_COLORS_YELLOW_GREEN
Definition: api_core.h:1295
CSG_Colors::Create
bool Create(void)
Definition: api_colors.cpp:204
CSG_Colors::Set_Palette
bool Set_Palette(int Index, bool bRevert=false, int nColors=11)
Definition: api_core.h:1380
CSG_Colors::Get_Color
long Get_Color(int Index) const
Definition: api_core.h:1357
SG_GET_G
#define SG_GET_G(rgb)
Definition: api_core.h:1257
SG_COLORS_DEFAULT
@ SG_COLORS_DEFAULT
Definition: api_core.h:1285
CSG_Colors::Set_Red
bool Set_Red(int Index, int Value)
Definition: api_colors.cpp:324
CSG_File::Read_Line
bool Read_Line(CSG_String &sLine) const
Definition: api_file.cpp:379
SG_COLORS_ASPECT_1
@ SG_COLORS_ASPECT_1
Definition: api_core.h:1313
SG_COLORS_WHITE_BLUE
@ SG_COLORS_WHITE_BLUE
Definition: api_core.h:1293
CSG_Colors::Get_Interpolated
long Get_Interpolated(double Index) const
Definition: api_core.h:1363
SG_COLORS_GREEN_RED
@ SG_COLORS_GREEN_RED
Definition: api_core.h:1297
CSG_Colors::Set_Green
bool Set_Green(int Index, int Value)
Definition: api_colors.cpp:330
CSG_Colors::Set_Count
bool Set_Count(int nColors)
Definition: api_colors.cpp:258
SG_COLORS_DEFAULT_BRIGHT
@ SG_COLORS_DEFAULT_BRIGHT
Definition: api_core.h:1286
CSG_Colors::CSG_Colors
CSG_Colors(void)
Definition: api_colors.cpp:166
SG_Color_To_Text
CSG_String SG_Color_To_Text(long Color, bool bHexadecimal)
Definition: api_colors.cpp:138
SG_FILE_W
@ SG_FILE_W
Definition: api_core.h:1102
CSG_File::is_Open
bool is_Open(void) const
Definition: api_core.h:1135
SG_COLORS_BLACK_GREEN
@ SG_COLORS_BLACK_GREEN
Definition: api_core.h:1289
CSG_Colors::operator=
CSG_Colors & operator=(const CSG_Colors &Colors)
Definition: api_colors.cpp:1023
CSG_String::Format
static CSG_String Format(const char *Format,...)
Definition: api_string.cpp:270
SG_COLORS_GREEN_GREY_BLUE
@ SG_COLORS_GREEN_GREY_BLUE
Definition: api_core.h:1303
CSG_String::Find
int Find(char Character, bool fromEnd=false) const
Definition: api_string.cpp:616
SG_COLORS_TOPOGRAPHY_3
@ SG_COLORS_TOPOGRAPHY_3
Definition: api_core.h:1311
CSG_File::Length
sLong Length(void) const
Definition: api_file.cpp:220
CSG_Colors::Set_Default
bool Set_Default(int nColors=11)
Definition: api_colors.cpp:837
SG_COLORS_ASPECT_3
@ SG_COLORS_ASPECT_3
Definition: api_core.h:1315
SG_COLORS_RED_GREY_GREEN
@ SG_COLORS_RED_GREY_GREEN
Definition: api_core.h:1302
CSG_String::AfterFirst
CSG_String AfterFirst(char Character) const
Definition: api_string.cpp:644
CSG_String::Clear
void Clear(void)
Definition: api_string.cpp:259
COLORS_SERIAL_VERSION_BINARY
#define COLORS_SERIAL_VERSION_BINARY
Definition: api_colors.cpp:1048
CSG_Colors::Get_Brightness
long Get_Brightness(int Index) const
Definition: api_core.h:1361
M_PI
#define M_PI
Definition: mat_tools.h:98
B
#define B
CSG_String
Definition: api_core.h:557
CSG_Colors::Get_Green
long Get_Green(int Index) const
Definition: api_core.h:1359
CSG_Colors::Serialize
bool Serialize(CSG_File &Stream, bool bSave, bool bBinary)
Definition: api_colors.cpp:1162
CSG_File::Printf
int Printf(const char *Format,...)
Definition: api_file.cpp:271
CSG_String::is_Empty
bool is_Empty(void) const
Definition: api_string.cpp:178
CSG_Colors::to_Text
bool to_Text(CSG_String &String)
Definition: api_colors.cpp:1236
SG_COLORS_COUNT
@ SG_COLORS_COUNT
Definition: api_core.h:1316
SG_COLORS_RED_BLUE
@ SG_COLORS_RED_BLUE
Definition: api_core.h:1299
CSG_String::AfterLast
CSG_String AfterLast(char Character) const
Definition: api_string.cpp:655
SG_COLORS_WHITE_RED
@ SG_COLORS_WHITE_RED
Definition: api_core.h:1291
SG_COLORS_RED_GREEN_BLUE
@ SG_COLORS_RED_GREEN_BLUE
Definition: api_core.h:1304
CSG_Colors::~CSG_Colors
virtual ~CSG_Colors(void)
Definition: api_colors.cpp:193
SG_COLORS_PRECIPITATION
@ SG_COLORS_PRECIPITATION
Definition: api_core.h:1312
CSG_File::Write
size_t Write(void *Buffer, size_t Size, size_t Count=1) const
Definition: api_file.cpp:354
CSG_Colors::Random
bool Random(void)
Definition: api_colors.cpp:966
SG_Realloc
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
Definition: api_memory.cpp:77
SG_COLORS_RED_GREEN
@ SG_COLORS_RED_GREEN
Definition: api_core.h:1298
SG_COLORS_GREEN_RED_BLUE
@ SG_COLORS_GREEN_RED_BLUE
Definition: api_core.h:1306
CSG_Colors::Save
bool Save(const CSG_String &File_Name, bool bBinary)
Definition: api_colors.cpp:1133
CSG_Colors::Assign
bool Assign(const CSG_Colors &Colors)
Definition: api_colors.cpp:1031
SG_COLORS_TOPOGRAPHY_2
@ SG_COLORS_TOPOGRAPHY_2
Definition: api_core.h:1310
SG_GET_RGBA
#define SG_GET_RGBA(r, g, b, a)
Definition: api_core.h:1254
CSG_Colors
Definition: api_core.h:1329
CSG_Colors::Set_Ramp_Brighness
bool Set_Ramp_Brighness(int Brightness_A, int Brightness_B)
Definition: api_colors.cpp:917