Mercurial > hg > minimon
comparison fbt.c @ 8:66c77f9ba9b9
convert rgba -> rgb
| author | Peter Meerwald <pmeerw@pmeerw.net> |
|---|---|
| date | Sat, 14 May 2011 21:05:59 +0200 |
| parents | e8957085fe8a |
| children | c7af696b6221 |
comparison
equal
deleted
inserted
replaced
| 7:5c00b239e1c8 | 8:66c77f9ba9b9 |
|---|---|
| 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 <unistd.h> |
| 5 #include <sys/ioctl.h> | 5 #include <sys/ioctl.h> |
| 6 #include <sys/mman.h> | |
| 6 | 7 |
| 7 #include "linux/fb.h" | 8 #include "linux/fb.h" |
| 8 | 9 |
| 9 #include "common.h" | 10 #include "common.h" |
| 10 | 11 |
| 30 printf("id %s\n", sif.id); | 31 printf("id %s\n", sif.id); |
| 31 printf("type %d, aux %d\n", sif.type, sif.type_aux); | 32 printf("type %d, aux %d\n", sif.type, sif.type_aux); |
| 32 printf("visual %d\n", sif.visual); | 33 printf("visual %d\n", sif.visual); |
| 33 printf("accel %d\n", sif.accel); | 34 printf("accel %d\n", sif.accel); |
| 34 printf("line length %d\n", sif.line_length); | 35 printf("line length %d\n", sif.line_length); |
| 36 printf("mem %d\n", sif.smem_len); | |
| 35 | 37 |
| 36 struct fb_var_screeninfo siv; | 38 struct fb_var_screeninfo siv; |
| 37 if (ioctl(fd, FBIOGET_VSCREENINFO, &siv) < 0) { | 39 if (ioctl(fd, FBIOGET_VSCREENINFO, &siv) < 0) { |
| 38 perror(""); | 40 perror(""); |
| 39 exit(EXIT_FAILURE); | 41 exit(EXIT_FAILURE); |
| 40 } | 42 } |
| 41 | 43 |
| 42 printf("res x %d y %d\n", siv.xres, siv.yres); | 44 printf("res x %d y %d\n", siv.xres, siv.yres); |
| 43 printf("bpp %d\n", siv.bits_per_pixel); | 45 printf("bpp %d\n", siv.bits_per_pixel); |
| 44 | 46 |
| 47 size_t fb_mem_size = siv.xres * siv.yres * siv.bits_per_pixel / 8; | |
| 48 void *fb_mem = mmap(NULL, fb_mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | |
| 49 if (fb_mem == MAP_FAILED) { | |
| 50 perror(""); | |
| 51 exit(EXIT_FAILURE); | |
| 52 } | |
| 53 | |
| 45 printf("-------------\n"); | 54 printf("-------------\n"); |
| 46 fflush(stdout); | 55 fflush(stdout); |
| 47 | 56 |
| 48 jpg_buf_t jpg_buf = build_jpg_from_fb(fd, siv.xres, siv.yres); | 57 jpg_buf_t jpg_buf = build_jpg_from_fb((unsigned char *)fb_mem, siv.xres, siv.yres, siv.bits_per_pixel); |
| 49 | 58 |
| 59 munmap(fb_mem, fb_mem_size); | |
| 50 close(fd); | 60 close(fd); |
| 51 | 61 |
| 52 printf("jpg %ld\n", jpg_buf.size); | 62 printf("jpg %ld\n", jpg_buf.size); |
| 53 | 63 |
| 54 FILE *f = fopen("test.jpg", "wb"); | 64 FILE *f = fopen("test.jpg", "wb"); |
