summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/read_image.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/read_image.c')
-rw-r--r--apps/plugins/lib/read_image.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/plugins/lib/read_image.c b/apps/plugins/lib/read_image.c
new file mode 100644
index 0000000000..0420ed8188
--- /dev/null
+++ b/apps/plugins/lib/read_image.c
@@ -0,0 +1,55 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2009 by Andrew Mahone
11*
12* This is a wrapper for the core jpeg_load.c
13*
14* This program is free software; you can redistribute it and/or
15* modify it under the terms of the GNU General Public License
16* as published by the Free Software Foundation; either version 2
17* of the License, or (at your option) any later version.
18*
19* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20* KIND, either express or implied.
21*
22****************************************************************************/
23
24#include <plugin.h>
25#include "feature_wrappers.h"
26
27int read_image_file(const char* filename, struct bitmap *bm, int maxsize,
28 int format, const struct custom_format *cformat)
29{
30#if LCD_DEPTH > 1
31 int namelen = rb->strlen(filename);
32 if (rb->strcmp(filename + namelen - 4, ".bmp"))
33 return read_jpeg_file(filename, bm, maxsize, format, cformat);
34 else
35#endif
36 return scaled_read_bmp_file(filename, bm, maxsize, format, cformat);
37}
38
39int read_image_file_offset(int offset, const char* filename, struct bitmap *bm,
40 int maxsize, int format,
41 const struct custom_format *cformat)
42{
43 int fd = rb->open(filename, O_RDONLY);
44 if (fd < 0)
45 return fd;
46 if (offset != rb->lseek(fd, offset, SEEK_SET))
47 return -1;
48#if LCD_DEPTH > 1
49 int namelen = rb->strlen(filename);
50 if (rb->strcmp(filename + namelen - 4, ".bmp"))
51 return read_jpeg_fd(fd, bm, maxsize, format, cformat);
52 else
53#endif
54 return scaled_read_bmp_fd(fd, bm, maxsize, format, cformat);
55}