Color Map

Source

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <math.h>
 5 
 6 #define XLEN 1024
 7 #define YLEN 1024
 8 
 9 int main()
10 {
11     FILE *fp = fopen("out.ppm", "wb");
12     
13     fprintf(fp, "P6\n%d %d\n255\n", XLEN, YLEN);
14     for(int i=0;i<XLEN;i++)
15         for(int j=0;j<YLEN;j++)
16             fprintf(fp, "%c%c%c\0", 
17                 i*256/XLEN, 
18                 j*256/YLEN, 
19                 255-((i-j)*(i-j)*256/XLEN/YLEN)
20             );//RGB
21     
22     fclose(fp);
23     return 0;
24 }

 

posted on 2022-08-25 10:35  acd407  阅读(17)  评论(0)    收藏  举报

导航