From 54e6eb3bdaea5a904d77a50866cb400857427c08 Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Fri, 1 May 2009 23:31:43 +0000 Subject: Search for, and load, JPEG album art files. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20837 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'apps/buffering.c') diff --git a/apps/buffering.c b/apps/buffering.c index a4d425f..66bd22f 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -53,6 +53,7 @@ #include "metadata.h" #ifdef HAVE_ALBUMART #include "albumart.h" +#include "jpeg_load.h" #endif #define GUARD_BUFSIZE (32*1024) @@ -830,9 +831,10 @@ static bool fill_buffer(void) /* Given a file descriptor to a bitmap file, write the bitmap data to the buffer, with a struct bitmap and the actual data immediately following. Return value is the total size (struct + data). */ -static int load_bitmap(int fd) +static int load_image(int fd, const char *path) { int rc; + int pathlen = strlen(path); struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; /* FIXME: alignment may be needed for the data buffer. */ bmp->data = &buffer[buf_widx + sizeof(struct bitmap)]; @@ -846,8 +848,12 @@ static int load_bitmap(int fd) get_albumart_size(bmp); - rc = read_bmp_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| - FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); + if (strcmp(path + pathlen - 4, ".bmp")) + rc = read_jpeg_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| + FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); + else + rc = read_bmp_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| + FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); return rc + (rc > 0 ? sizeof(struct bitmap) : 0); } #endif @@ -942,7 +948,7 @@ int bufopen(const char *file, size_t offset, enum data_type type) /* Bitmap file: we load the data instead of the file */ int rc; mutex_lock(&llist_mutex); /* Lock because load_bitmap yields */ - rc = load_bitmap(fd); + rc = load_image(fd, file); mutex_unlock(&llist_mutex); if (rc <= 0) { -- cgit v1.1