diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-01 23:31:43 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-01 23:31:43 +0000 |
commit | 54e6eb3bdaea5a904d77a50866cb400857427c08 (patch) | |
tree | b4fcb445f7e005cf50db9bdb36bcb5cb6fbddb76 /apps/buffering.c | |
parent | 60d420938372477226184fb9012de7f6b4ea2d83 (diff) |
Search for, and load, JPEG album art files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20837 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r-- | apps/buffering.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index a4d425fb1d..66bd22f12d 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) { |