aboutsummaryrefslogtreecommitdiff
path: root/plotlib/colorstuff/rgbtest.c
blob: f30a0a0044c97d590f5ed2fa9e5f03bee728cc7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "rgbtbl.h"

main(argc,argv)
char **argv;
int argc;
{

int IC,ic,ncols;
int i,n,ired,igrn,iblu;
char teststr[50], c;

IC = sizeof(Colordef);
ic = sizeof(colordef);
ncols = ic/IC;

printf("Colordef %d\n",IC);
printf("colordef %d\n",ic);
printf("#entries %d\n",ncols);

printf("\nEnter color string: ");

/*if ((c=fgetc(stdin)) != '\n')
ungetc(c,stdin); */

fgets(teststr,50,stdin);
printf("strlen = %d\n",strlen(teststr));

if ((n=strlen(teststr)) != 0) {
    while(n > 0 && teststr[--n] == '\n')
      teststr[n] = '\0'; } 

/*fscanf(stdin,"%s",teststr);*/
printf("\nTest string = %s\n",teststr);

for (i=0; i < ncols; i++) {
  if(!strcasecmp(colordef[i].name,teststr)) {

   printf("test  string %s found at %d\n",teststr,i); 
   printf("found string %s code %d\n",colordef[i].name,colordef[i].rgb); 

   ired = 0x000000ff & (colordef[i].rgb >> 16);
   igrn = 0x000000ff & (colordef[i].rgb >> 8); 
   iblu = 0x000000ff & (colordef[i].rgb); 

   printf("red = %d\ngrn = %d\nblu = %d\n",ired,igrn,iblu);
  }
}

}