 |
SAGA API
v9.2
|
Go to the documentation of this file.
87 const char *s = Text.
b_str();
unsigned long c;
89 if( sscanf(s + 1,
"%lx", &c) == 1 )
91 switch( Text.
Length() - 1 )
96 (
unsigned char)((c >> 24) & 0xFF),
97 (
unsigned char)((c >> 16) & 0xFF),
98 (
unsigned char)((c >> 8) & 0xFF)
104 (
unsigned char)((c >> 24) & 0xFF),
105 (
unsigned char)((c >> 16) & 0xFF),
106 (
unsigned char)((c >> 8) & 0xFF),
107 (
unsigned char)((c ) & 0xFF)
114 (
unsigned char)(((c >> 12) & 0xF) * 0x11),
115 (
unsigned char)(((c >> 8) & 0xF) * 0x11),
116 (
unsigned char)(((c >> 4) & 0xF) * 0x11)
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)
144 Text.
Printf(
"#%02X%02X%02X",
152 Text.
Printf(
"%ld", Color);
189 Create(nColors, Palette, bRevert);
212 if( Colors.m_nColors > 0 )
214 m_nColors = Colors.m_nColors;
215 m_Colors = (
long *)
SG_Realloc(m_Colors, m_nColors *
sizeof(
long));
217 memcpy(m_Colors, Colors.m_Colors, m_nColors *
sizeof(
long));
260 if( nColors == m_nColors )
279 m_Colors = (
long *)
SG_Realloc(m_Colors, m_nColors *
sizeof(
long));
287 m_Colors[i] = Colors[(int)(i * dStep)];
307 if( Index >= 0 && Index < m_nColors )
309 m_Colors[Index] = Color;
351 else if( Value > 255 )
360 ds = (r + g + b) / 3.0;
369 _Set_Brightness(r, g, b);
373 r = g = b = Value / 3.0;
376 return(
Set_Color(Index, (
int)r, (
int)g, (
int)b) );
380 void CSG_Colors::_Set_Brightness(
double &a,
double &b,
double &c,
int Pass)
386 addSum = (int)((a - 255) / 2.0);
394 addSum = (int)(b - 255);
406 addSum = (int)(c - 255);
419 _Set_Brightness(b, c, a, Pass + 1);
470 default :
return(
_TL(
"" ) );
842 m_Colors = (
long *)
SG_Realloc(m_Colors, m_nColors *
sizeof(
long));
846 for(
int i=0; i<
Get_Count(); i++, d+=dStep)
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))
870 if( iColor_A > iColor_B )
888 int n = iColor_B - iColor_A;
893 double dr = (double)(
SG_GET_R(Color_B) - ar) / (
double)n;
896 double dg = (double)(
SG_GET_G(Color_B) - ag) / (
double)n;
899 double db = (double)(
SG_GET_B(Color_B) - ab) / (
double)n;
901 for(
int i=0; i<=n; i++)
925 if( iColor_A > iColor_B )
943 int n = iColor_B - iColor_A;
947 double dBrightness = (double)(Brightness_B - Brightness_A) / (double)n;
949 for(
int i=0; i<=n; i++)
951 Set_Brightness(iColor_A + i, (
int)(Brightness_A + i * dBrightness));
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)
994 for(
int i=0, j=
Get_Count()-1; i<j; i++, j--)
1033 return(
Create(Colors) );
1039 return( pColors ?
Create(*pColors) :
false );
1048 #define COLORS_SERIAL_VERSION_BINARY "SAGA_COLORPALETTE_VERSION_0.100_BINARY"
1049 #define COLORS_SERIAL_VERSION__ASCII "SAGA_COLORPALETTE_VERSION_0.100__ASCII"
1068 return(
Serialize(Stream,
false,
false) );
1079 Stream.
Read(&nColors,
sizeof(nColors));
1089 for(
int i=0; i<nColors; i++)
1091 Stream.
Read(c, ValueSize);
1109 Stream.
Read(&nColors,
sizeof(
short));
1111 if( Stream.
Length() == (
int)(
sizeof(
short) + 3 * nColors) &&
Set_Count(nColors) )
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));
1117 for(
int i=0; i<nColors; i++)
1173 Stream.
Write(&m_nColors,
sizeof(m_nColors));
1174 Stream.
Write(m_Colors,
sizeof(
long), m_nColors);
1181 Stream.
Read(&nColors,
sizeof(m_nColors));
1185 Stream.
Read(m_Colors,
sizeof(
long), m_nColors);
1258 for(
int i=0, j=0; i<
Get_Count(); i++, j+=12)
bool Set_Brightness(int Index, int Value)
bool Set_Color(int Index, long Color)
virtual bool Open(const CSG_String &FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
bool from_Text(const CSG_String &String)
#define SG_GET_RGB(r, g, b)
@ SG_COLORS_RED_BLUE_GREEN
int Printf(const char *Format,...)
bool Seek_Start(void) const
size_t Length(void) const
bool SG_Color_From_Text(const CSG_String &Text, long &Color)
CSG_String SG_Colors_Get_Name(int Index)
const char * b_str(void) const
bool Load(const CSG_String &File_Name)
CSG_String Mid(size_t first, size_t count=0) const
@ SG_COLORS_RED_GREY_BLUE
static CSG_String Get_Predefined_Name(int Identifier)
long Get_Blue(int Index) const
static double Get_Uniform(void)
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
long SG_Color_Get_Random(void)
SG_Char Get_Char(size_t i) const
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
bool Set_Blue(int Index, int Value)
long Get_Red(int Index) const
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
bool Set_Ramp(long Color_A, long Color_B)
static int Get_Predefined_Count(void)
bool Set_Predefined(int Index, bool bRevert=false, int nColors=11)
#define COLORS_SERIAL_VERSION__ASCII
int Get_Count(void) const
bool Set_Palette(int Index, bool bRevert=false, int nColors=11)
long Get_Color(int Index) const
bool Set_Red(int Index, int Value)
bool Read_Line(CSG_String &sLine) const
long Get_Interpolated(double Index) const
bool Set_Green(int Index, int Value)
bool Set_Count(int nColors)
@ SG_COLORS_DEFAULT_BRIGHT
CSG_String SG_Color_To_Text(long Color, bool bHexadecimal)
CSG_Colors & operator=(const CSG_Colors &Colors)
static CSG_String Format(const char *Format,...)
@ SG_COLORS_GREEN_GREY_BLUE
int Find(char Character, bool fromEnd=false) const
bool Set_Default(int nColors=11)
@ SG_COLORS_RED_GREY_GREEN
CSG_String AfterFirst(char Character) const
#define COLORS_SERIAL_VERSION_BINARY
long Get_Brightness(int Index) const
long Get_Green(int Index) const
bool Serialize(CSG_File &Stream, bool bSave, bool bBinary)
int Printf(const char *Format,...)
bool is_Empty(void) const
bool to_Text(CSG_String &String)
CSG_String AfterLast(char Character) const
@ SG_COLORS_RED_GREEN_BLUE
virtual ~CSG_Colors(void)
@ SG_COLORS_PRECIPITATION
size_t Write(void *Buffer, size_t Size, size_t Count=1) const
SAGA_API_DLL_EXPORT void * SG_Realloc(void *memblock, size_t size)
@ SG_COLORS_GREEN_RED_BLUE
bool Save(const CSG_String &File_Name, bool bBinary)
bool Assign(const CSG_Colors &Colors)
#define SG_GET_RGBA(r, g, b, a)
bool Set_Ramp_Brighness(int Brightness_A, int Brightness_B)