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