- for(i = 0; i < 256; i++) {
- lut[i][0] = ((i >> 6) * 0x55);
- lut[i][1] = ((((i >> 3) & 7) * 0x49) >> 1);
- lut[i][2] = (((i & 7) * 0x49) >> 1);
- }
-
- for(i = 0; i < sizeof(screen_conv); i += 3) {
- screen_conv[i] = lut[screen[i/3]][0];
- screen_conv[i+1] = lut[screen[i/3]][1];
- screen_conv[i+2] = lut[screen[i/3]][2];
- }
-
- lt = time(NULL);
- strftime(filename, sizeof(filename), "screen_%Y%m%d-%H%M%S.ppm", localtime(<));
-
- fp = fopen (filename, "w");
- fprintf(fp, "P6\n320 234\n255\n");
- fwrite(screen_conv, sizeof(screen_conv), 1, fp);
- fclose (fp);
+ strftime(filename, sizeof(filename), "screen_%Y%m%d-%H%M%S.png", localtime(<));
+ fd=open(filename, O_CREAT|O_WRONLY, 0644);
+ png = lcd2png(screen, &imglen);
+ write(fd, png, imglen);
+ close(fd);