mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
X11 colors conversion program.
This commit is contained in:
parent
ca0053d4d4
commit
e87abfa7bc
42
extra/x11_colors.c
Normal file
42
extra/x11_colors.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE* f = fopen( "rgb.txt", "rb" );
|
||||
|
||||
char buf[1024];
|
||||
int off = 0;
|
||||
for(;;)
|
||||
{
|
||||
int sz = fread( buf+off, 1, 1, f );
|
||||
if( buf[off] == '\r' || buf[off] == '\n' || sz == 0 )
|
||||
{
|
||||
if( off == 0 )
|
||||
{
|
||||
if( sz == 0 ) break;
|
||||
continue;
|
||||
}
|
||||
int ok = 1;
|
||||
for( int i=13; i<off; i++ )
|
||||
{
|
||||
if( buf[i] == ' ' ) ok = 0;
|
||||
}
|
||||
if( ok == 1 )
|
||||
{
|
||||
buf[off] = '\0';
|
||||
int r, g, b;
|
||||
sscanf( buf, "%i %i %i", &r, &g, &b );
|
||||
printf( "%s = 0x%02x%02x%02x,\n", buf+13, r, g, b );
|
||||
}
|
||||
off = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
off++;
|
||||
}
|
||||
if( sz == 0 ) break;
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
}
|
Loading…
Reference in New Issue
Block a user