diff options
Diffstat (limited to 'apps/plugins/lib')
| -rw-r--r-- | apps/plugins/lib/SOURCES | 1 | ||||
| -rw-r--r-- | apps/plugins/lib/feature_wrappers.h | 2 | ||||
| -rw-r--r-- | apps/plugins/lib/read_image.c | 55 | ||||
| -rw-r--r-- | apps/plugins/lib/read_image.h | 34 |
4 files changed, 92 insertions, 0 deletions
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 7dda416..dfdd569 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES @@ -41,6 +41,7 @@ xlcd_core.c xlcd_draw.c xlcd_scroll.c pluginlib_bmp.c +read_image.c #ifdef HAVE_LCD_COLOR bmp_smooth_scale.c #endif diff --git a/apps/plugins/lib/feature_wrappers.h b/apps/plugins/lib/feature_wrappers.h index 22ce779..cf840e6 100644 --- a/apps/plugins/lib/feature_wrappers.h +++ b/apps/plugins/lib/feature_wrappers.h @@ -43,8 +43,10 @@ */ #if LCD_DEPTH > 1 #define scaled_read_bmp_file rb->read_bmp_file +#define scaled_read_bmp_fd rb->read_bmp_fd #else #define scaled_read_bmp_file read_bmp_file +#define scaled_read_bmp_fd read_bmp_fd #endif #endif diff --git a/apps/plugins/lib/read_image.c b/apps/plugins/lib/read_image.c new file mode 100644 index 0000000..0420ed8 --- /dev/null +++ b/apps/plugins/lib/read_image.c @@ -0,0 +1,55 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This is a wrapper for the core jpeg_load.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#include <plugin.h> +#include "feature_wrappers.h" + +int read_image_file(const char* filename, struct bitmap *bm, int maxsize, + int format, const struct custom_format *cformat) +{ +#if LCD_DEPTH > 1 + int namelen = rb->strlen(filename); + if (rb->strcmp(filename + namelen - 4, ".bmp")) + return read_jpeg_file(filename, bm, maxsize, format, cformat); + else +#endif + return scaled_read_bmp_file(filename, bm, maxsize, format, cformat); +} + +int read_image_file_offset(int offset, const char* filename, struct bitmap *bm, + int maxsize, int format, + const struct custom_format *cformat) +{ + int fd = rb->open(filename, O_RDONLY); + if (fd < 0) + return fd; + if (offset != rb->lseek(fd, offset, SEEK_SET)) + return -1; +#if LCD_DEPTH > 1 + int namelen = rb->strlen(filename); + if (rb->strcmp(filename + namelen - 4, ".bmp")) + return read_jpeg_fd(fd, bm, maxsize, format, cformat); + else +#endif + return scaled_read_bmp_fd(fd, bm, maxsize, format, cformat); +} diff --git a/apps/plugins/lib/read_image.h b/apps/plugins/lib/read_image.h new file mode 100644 index 0000000..3e23668 --- /dev/null +++ b/apps/plugins/lib/read_image.h @@ -0,0 +1,34 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This is a wrapper for the core jpeg_load.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#ifndef _LIB_READ_IMAGE_H_ +#define _LIB_READ_IMAGE_H_ +#include <plugin.h> + +int read_image_file(const char* filename, struct bitmap *bm, int maxsize, + int format, const struct custom_format *cformat); +int read_image_file_offset(int offset, const char* filename, struct bitmap *bm, + int maxsize, int format, + const struct custom_format *cformat); +#endif + |