forked from len0rd/rockbox
Add read_<image>_fd functions to plugin API, add feature_wrappers.h handling for them, and add read_image.[ch] wrapper for reading image files with automatic type detection.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20840 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
75f2629778
commit
3d4c68bb06
6 changed files with 105 additions and 5 deletions
|
@ -643,8 +643,12 @@ static const struct plugin_api rockbox_api = {
|
|||
lcd_pal256_update_pal,
|
||||
#endif
|
||||
#endif
|
||||
#if defined(HAVE_LCD_BITMAP) && LCD_DEPTH > 1
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#if LCD_DEPTH > 1
|
||||
read_jpeg_file,
|
||||
read_jpeg_fd,
|
||||
#endif
|
||||
read_bmp_fd,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -79,9 +79,7 @@ void* plugin_get_buffer(size_t *buffer_size);
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "screendump.h"
|
||||
#include "scrollbar.h"
|
||||
#if LCD_DEPTH > 1
|
||||
#include "jpeg_load.h"
|
||||
#endif
|
||||
#include "../recorder/bmp.h"
|
||||
#endif
|
||||
#include "statusbar.h"
|
||||
|
@ -131,7 +129,7 @@ void* plugin_get_buffer(size_t *buffer_size);
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 148
|
||||
#define PLUGIN_API_VERSION 149
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
|
@ -806,9 +804,15 @@ struct plugin_api {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LCD_BITMAP) && LCD_DEPTH > 1
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#if LCD_DEPTH > 1
|
||||
int (*read_jpeg_file)(const char* filename, struct bitmap *bm, int maxsize,
|
||||
int format, const struct custom_format *cformat);
|
||||
int (*read_jpeg_fd)(int fd, struct bitmap *bm, int maxsize,
|
||||
int format, const struct custom_format *cformat);
|
||||
#endif
|
||||
int (*read_bmp_fd)(int fd, struct bitmap *bm, int maxsize,
|
||||
int format, const struct custom_format *cformat);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
55
apps/plugins/lib/read_image.c
Normal file
55
apps/plugins/lib/read_image.c
Normal file
|
@ -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);
|
||||
}
|
34
apps/plugins/lib/read_image.h
Normal file
34
apps/plugins/lib/read_image.h
Normal file
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue