Mercurial > hg > minimon
comparison fbt.c @ 3:e8957085fe8a
working
author | Peter Meerwald <pmeerw@pmeerw.net> |
---|---|
date | Sun, 08 May 2011 23:08:45 +0200 |
parents | bac8ed8d6eb9 |
children | 66c77f9ba9b9 |
comparison
equal
deleted
inserted
replaced
2:bac8ed8d6eb9 | 3:e8957085fe8a |
---|---|
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include <stdio.h> | 2 #include <stdio.h> |
3 #include <fcntl.h> | 3 #include <fcntl.h> |
4 #include <unistd.h> | |
4 #include <sys/ioctl.h> | 5 #include <sys/ioctl.h> |
5 | 6 |
6 #include "linux/fb.h" | 7 #include "linux/fb.h" |
7 | 8 |
9 #include "common.h" | |
10 | |
8 int main(int argc, char *argv[]) { | 11 int main(int argc, char *argv[]) { |
9 | 12 |
10 int fd = open("/dev/fb0", O_RDWR); | 13 if (argc != 2) { |
14 fprintf(stderr, "usage: fbt /dev/fbX\n"); | |
15 exit(EXIT_FAILURE); | |
16 } | |
17 | |
18 int fd = open(argv[1], O_RDWR); | |
11 if (fd < 0) { | 19 if (fd < 0) { |
12 perror(""); | 20 perror(""); |
13 exit(EXIT_FAILURE); | 21 exit(EXIT_FAILURE); |
14 } | 22 } |
15 | 23 |
32 } | 40 } |
33 | 41 |
34 printf("res x %d y %d\n", siv.xres, siv.yres); | 42 printf("res x %d y %d\n", siv.xres, siv.yres); |
35 printf("bpp %d\n", siv.bits_per_pixel); | 43 printf("bpp %d\n", siv.bits_per_pixel); |
36 | 44 |
45 printf("-------------\n"); | |
46 fflush(stdout); | |
47 | |
48 jpg_buf_t jpg_buf = build_jpg_from_fb(fd, siv.xres, siv.yres); | |
49 | |
50 close(fd); | |
51 | |
52 printf("jpg %ld\n", jpg_buf.size); | |
53 | |
54 FILE *f = fopen("test.jpg", "wb"); | |
55 if (!f) { | |
56 fprintf(stderr, "fopen failed\n"); | |
57 exit(EXIT_FAILURE); | |
58 } | |
59 | |
60 fwrite(jpg_buf.ptr, 1, jpg_buf.size, f); | |
61 | |
62 fclose(f); | |
63 | |
64 free(jpg_buf.ptr); | |
65 | |
37 exit(EXIT_SUCCESS); | 66 exit(EXIT_SUCCESS); |
38 } | 67 } |