|
SAGA API
v9.6
|
Go to the documentation of this file.
93 const char *s = Text.
b_str();
unsigned long c;
95 if( sscanf(s + 1,
"%lx", &c) == 1 )
97 switch( Text.
Length() - 1 )
102 (
unsigned char)((c >> 24) & 0xFF),
103 (
unsigned char)((c >> 16) & 0xFF),
104 (
unsigned char)((c >> 8) & 0xFF)
110 (
unsigned char)((c >> 24) & 0xFF),
111 (
unsigned char)((c >> 16) & 0xFF),
112 (
unsigned char)((c >> 8) & 0xFF),
113 (
unsigned char)((c ) & 0xFF)
120 (
unsigned char)(((c >> 12) & 0xF) * 0x11),
121 (
unsigned char)(((c >> 8) & 0xF) * 0x11),
122 (
unsigned char)(((c >> 4) & 0xF) * 0x11)
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)
150 Text.
Printf(
"#%02X%02X%02X",
158 Text.
Printf(
"%ld", Color);
195 Create(nColors, Palette, bRevert);
218 if( Colors.m_nColors > 0 )
220 m_nColors = Colors.m_nColors;
221 m_Colors = (
long *)
SG_Realloc(m_Colors, m_nColors *
sizeof(
long));
223 memcpy(m_Colors, Colors.m_Colors, m_nColors *
sizeof(
long));
266 if( nColors == m_nColors )
285 m_Colors = (
long *)
SG_Realloc(m_Colors, m_nColors *
sizeof(
long));
293 m_Colors[i] = Colors[(int)(i * dStep)];
313 if( Index >= 0 && Index < m_nColors )
315 m_Colors[Index] = Color;
357 else if( Value > 255 )
366 ds = (r + g + b) / 3.0;
375 _Set_Brightness(r, g, b);
379 r = g = b = Value / 3.0;
382 return(
Set_Color(Index, (
int)r, (
int)g, (
int)b) );
386 void CSG_Colors::_Set_Brightness(
double &a,
double &b,
double &c,
int Pass)
392 addSum = (int)((a - 255) / 2.0);
400 addSum = (int)(b - 255);
412 addSum = (int)(c - 255);
425 _Set_Brightness(b, c, a, Pass + 1);
476 default :
return(
_TL(
"" ) );
848 m_Colors = (
long *)
SG_Realloc(m_Colors, m_nColors *
sizeof(
long));
852 for(
int i=0; i<
Get_Count(); i++, d+=dStep)
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))
876 if( iColor_A > iColor_B )
894 int n = iColor_B - iColor_A;
899 double dr = (double)(
SG_GET_R(Color_B) - ar) / (
double)n;
902 double dg = (double)(
SG_GET_G(Color_B) - ag) / (
double)n;
905 double db = (double)(
SG_GET_B(Color_B) - ab) / (
double)n;
907 for(
int i=0; i<=n; i++)
931 if( iColor_A > iColor_B )
949 int n = iColor_B - iColor_A;
953 double dBrightness = (double)(Brightness_B - Brightness_A) / (double)n;
955 for(
int i=0; i<=n; i++)
957 Set_Brightness(iColor_A + i, (
int)(Brightness_A + i * dBrightness));
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)
1000 for(
int i=0, j=
Get_Count()-1; i<j; i++, j--)
1039 return(
Create(Colors) );
1045 return( pColors ?
Create(*pColors) :
false );
1054 #define COLORS_SERIAL_VERSION_BINARY "SAGA_COLORPALETTE_VERSION_0.100_BINARY"
1055 #define COLORS_SERIAL_VERSION__ASCII "SAGA_COLORPALETTE_VERSION_0.100__ASCII"
1074 return(
Serialize(Stream,
false,
false) );
1085 Stream.
Read(&nColors,
sizeof(nColors));
1095 for(
int i=0; i<nColors; i++)
1097 Stream.
Read(c, ValueSize);
1115 Stream.
Read(&nColors,
sizeof(
short));
1117 if( Stream.
Length() == (
int)(
sizeof(
short) + 3 * nColors) &&
Set_Count(nColors) )
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));
1123 for(
int i=0; i<nColors; i++)
1179 Stream.
Write(&m_nColors,
sizeof(m_nColors));
1180 Stream.
Write(m_Colors,
sizeof(
long), m_nColors);
1187 Stream.
Read(&nColors,
sizeof(m_nColors));
1191 Stream.
Read(m_Colors,
sizeof(
long), m_nColors);
1264 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 SG_Color_From_RGB(int Red, int Green, int Blue, int Alpha)
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)