Hallo UFUN-Freaks,
anbei ein Beispielprogramm.
Gruß Michael
Date: 28-FEB-2002
Subject: Sample API function - load color definition file
static void strip_trailing_spaces(char *s)
{
int ii;
for (ii = strlen(s) - 1; s[ii] == ' '; ii--) s[ii] = '\0';
}
static void load_color_definition_file(char *cdf_spec)
{
int
ii;
double
rgb[3];
char
a_line[MAX_LINE_SIZE+1],
color_name[UF_DISP_MAX_NAME_SIZE+1],
*ptr;
FILE
*cdf;
if ((cdf = fopen(cdf_spec, "r")) != NULL)
{
/* Read 4 header lines */
for (ii = 0; ii < 4; ii++)
fgets(a_line, MAX_LINE_SIZE, cdf);
ii = 0;
while ((fgets(a_line, MAX_LINE_SIZE, cdf)) != NULL)
{
strncpy(color_name, a_line, UF_DISP_MAX_NAME_SIZE);
color_name[UF_DISP_MAX_NAME_SIZE] = '\0';
strip_trailing_spaces(color_name);
ptr = a_line + 32;
rgb[0] = atof(ptr);
ptr = ptr + 11;
rgb[1] = atof(ptr);
ptr = ptr + 11;
rgb[2] = atof(ptr);
UF_CALL(UF_DISP_set_color(ii, UF_DISP_rgb_model, color_name, rgb));
ii++;
}
fclose(cdf);
UF_CALL(UF_DISP_load_color_table());
}
}
------------------
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP