1 2 #include <stdio.h> 3 #include <math.h> 4 #include <glib.h> 5 6 static int get_value(int i)7get_value (int i) 8 { 9 int x; 10 11 x = floor (256 * (0.5 + 0.5 * sin (i * 2 * G_PI / 256))); 12 if (x > 255) 13 x = 255; 14 return x; 15 } 16 17 int main(int argc,char * argv[])18main (int argc, char *argv[]) 19 { 20 int i; 21 int j; 22 23 printf ("static const guint8\n"); 24 printf ("sine_table[256] = {\n"); 25 for (i = 0; i < 256; i += 8) { 26 printf (" "); 27 for (j = 0; j < 8; j++) { 28 printf ("%3d", get_value (i + j)); 29 if (j != 7) { 30 printf (", "); 31 } else { 32 if (i + j != 255) { 33 printf (",\n"); 34 } else { 35 printf ("\n"); 36 } 37 } 38 } 39 } 40 printf ("};\n"); 41 42 return 0; 43 } 44