summaryrefslogtreecommitdiff
path: root/apps/recorder/bmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/bmp.c')
-rw-r--r--apps/recorder/bmp.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index 01b57d2116..d6d836a6c5 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -72,19 +72,6 @@
72#pragma pack (push, 2) 72#pragma pack (push, 2)
73#endif 73#endif
74 74
75#ifndef PLUGIN
76#define API(x) x
77#else
78#define API(x) rb->x
79
80static const struct plugin_api *rb;
81
82void bmp_init(const struct plugin_api * api)
83{
84 rb = api;
85}
86#endif
87
88/* BMP header structure */ 75/* BMP header structure */
89struct bmp_header { 76struct bmp_header {
90 uint16_t type; /* signature - 'BM' */ 77 uint16_t type; /* signature - 'BM' */
@@ -137,15 +124,13 @@ static const struct uint8_rgb bitfields[3][3] = {
137 }, 124 },
138}; 125};
139 126
140#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ 127#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
141 defined(PLUGIN)
142/* the full 16x16 Bayer dither matrix may be calculated quickly with this table 128/* the full 16x16 Bayer dither matrix may be calculated quickly with this table
143*/ 129*/
144const unsigned char dither_table[16] = 130const unsigned char dither_table[16] =
145 { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }; 131 { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 };
146#endif 132#endif
147 133
148#ifndef PLUGIN
149#if ((LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)) \ 134#if ((LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)) \
150 || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH == 2) \ 135 || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH == 2) \
151 && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)) 136 && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED))
@@ -153,7 +138,6 @@ const unsigned short vi_pattern[4] = {
153 0x0101, 0x0100, 0x0001, 0x0000 138 0x0101, 0x0100, 0x0001, 0x0000
154}; 139};
155#endif 140#endif
156#endif
157 141
158/****************************************************************************** 142/******************************************************************************
159 * read_bmp_file() 143 * read_bmp_file()
@@ -168,7 +152,7 @@ int read_bmp_file(const char* filename,
168 const struct custom_format *cformat) 152 const struct custom_format *cformat)
169{ 153{
170 int fd, ret; 154 int fd, ret;
171 fd = API(open)(filename, O_RDONLY); 155 fd = open(filename, O_RDONLY);
172 156
173 /* Exit if file opening failed */ 157 /* Exit if file opening failed */
174 if (fd < 0) { 158 if (fd < 0) {
@@ -180,7 +164,7 @@ int read_bmp_file(const char* filename,
180 filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE), 164 filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE),
181 !!(format & FORMAT_KEEP_ASPECT)); 165 !!(format & FORMAT_KEEP_ASPECT));
182 ret = read_bmp_fd(fd, bm, maxsize, format, cformat); 166 ret = read_bmp_fd(fd, bm, maxsize, format, cformat);
183 API(close)(fd); 167 close(fd);
184 return ret; 168 return ret;
185} 169}
186 170
@@ -237,7 +221,7 @@ static unsigned int read_part_line(struct bmp_args *ba)
237#endif 221#endif
238 ibuf = ((unsigned char *)buf) + (BM_MAX_WIDTH << 2) - len; 222 ibuf = ((unsigned char *)buf) + (BM_MAX_WIDTH << 2) - len;
239 BDEBUGF("read_part_line: cols=%d len=%d\n",cols,len); 223 BDEBUGF("read_part_line: cols=%d len=%d\n",cols,len);
240 ret = API(read)(fd, ibuf, len); 224 ret = read(fd, ibuf, len);
241 if (ret != len) 225 if (ret != len)
242 { 226 {
243 DEBUGF("read_part_line: error reading image, read returned %d " 227 DEBUGF("read_part_line: error reading image, read returned %d "
@@ -324,7 +308,7 @@ static unsigned int read_part_line(struct bmp_args *ba)
324 if (pad > 0) 308 if (pad > 0)
325 { 309 {
326 BDEBUGF("seeking %d bytes to next line\n",pad); 310 BDEBUGF("seeking %d bytes to next line\n",pad);
327 API(lseek)(fd, pad, SEEK_CUR); 311 lseek(fd, pad, SEEK_CUR);
328 } 312 }
329#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 313#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \
330 defined(PLUGIN) 314 defined(PLUGIN)
@@ -422,7 +406,7 @@ int read_bmp_fd(int fd,
422#endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/ 406#endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/
423 407
424 /* read fileheader */ 408 /* read fileheader */
425 ret = API(read)(fd, &bmph, sizeof(struct bmp_header)); 409 ret = read(fd, &bmph, sizeof(struct bmp_header));
426 if (ret < 0) { 410 if (ret < 0) {
427 return ret * 10 - 2; 411 return ret * 10 - 2;
428 } 412 }
@@ -531,7 +515,7 @@ int read_bmp_fd(int fd,
531 int i; 515 int i;
532 union rgb_union pal; 516 union rgb_union pal;
533 for (i = 0; i < numcolors; i++) { 517 for (i = 0; i < numcolors; i++) {
534 if (API(read)(fd, &pal, sizeof(pal)) != (int)sizeof(pal)) 518 if (read(fd, &pal, sizeof(pal)) != (int)sizeof(pal))
535 { 519 {
536 DEBUGF("read_bmp_fd: Can't read color palette\n"); 520 DEBUGF("read_bmp_fd: Can't read color palette\n");
537 return -7; 521 return -7;
@@ -589,9 +573,9 @@ int read_bmp_fd(int fd,
589 } 573 }
590 574
591 /* Search to the beginning of the image data */ 575 /* Search to the beginning of the image data */
592 API(lseek)(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); 576 lseek(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET);
593 577
594 API(memset)(bitmap, 0, totalsize); 578 memset(bitmap, 0, totalsize);
595 579
596 struct bmp_args ba = { 580 struct bmp_args ba = {
597 .fd = fd, .padded_width = padded_width, .read_width = read_width, 581 .fd = fd, .padded_width = padded_width, .read_width = read_width,