1
0
Fork 0
forked from len0rd/rockbox

FS#6321: Universal Image Viewer

This unifies jpeg viewer, png viewer, and bmp viewer to one plugin, image viewer, so that you can navigate through different image formats.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28626 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-11-21 13:47:56 +00:00
parent eef21cb18a
commit e5b1a7d423
26 changed files with 582 additions and 478 deletions

View file

@ -1,2 +1 @@
bmp_ui.c
bmp.c

View file

@ -65,18 +65,13 @@ struct bitmap bmp;
/************************* Implementation ***************************/
bool img_ext(const char *ext)
{
if (!ext)
return false;
if (!rb->strcasecmp(ext,".bmp"))
return true;
else
return false;
}
#if defined(USEGSLIB) && (CONFIG_PLATFORM & PLATFORM_HOSTED)
/* hack: fix error "undefined reference to `_grey_info'". */
GREY_INFO_STRUCT
#endif /* USEGSLIB */
void draw_image_rect(struct image_info *info,
int x, int y, int width, int height)
static void draw_image_rect(struct image_info *info,
int x, int y, int width, int height)
{
struct t_disp* pdisp = (struct t_disp*)info->data;
#ifdef HAVE_LCD_COLOR
@ -95,7 +90,7 @@ void draw_image_rect(struct image_info *info,
#endif
}
int img_mem(int ds)
static int img_mem(int ds)
{
#ifndef USEGSLIB
return (bmp.width/ds) * (bmp.height/ds) * sizeof (fb_data);
@ -104,8 +99,8 @@ int img_mem(int ds)
#endif
}
int load_image(char *filename, struct image_info *info,
unsigned char *buf, ssize_t *buf_size)
static int load_image(char *filename, struct image_info *info,
unsigned char *buf, ssize_t *buf_size)
{
int w, h; /* used to center output */
long time; /* measured ticks */
@ -147,7 +142,7 @@ int load_image(char *filename, struct image_info *info,
}
#endif
#ifdef USE_PLUG_BUF
if (!plug_buf)
if (!iv->plug_buf)
#endif
{
while (size > *buf_size && bmp.width >= 2 && bmp.height >= 2 && ds < 8)
@ -174,7 +169,7 @@ int load_image(char *filename, struct image_info *info,
return PLUGIN_OUTOFMEM;
}
if (!running_slideshow)
if (!iv->running_slideshow)
{
rb->lcd_puts(0, 0, rb->strrchr(filename,'/')+1);
rb->lcd_putsf(0, 1, "loading %dx%d%s",
@ -204,7 +199,7 @@ int load_image(char *filename, struct image_info *info,
return PLUGIN_ERROR;
}
if (!running_slideshow)
if (!iv->running_slideshow)
{
rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ);
rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */
@ -212,7 +207,7 @@ int load_image(char *filename, struct image_info *info,
rb->lcd_update();
}
#ifdef DISK_SPINDOWN
else if (immediate_ata_off)
else if(iv->immediate_ata_off)
{
/* running slideshow and time is long enough: power down disk */
rb->storage_sleep();
@ -223,7 +218,7 @@ int load_image(char *filename, struct image_info *info,
buf_images = buf_root = buf + size;
buf_images_size = root_size = *buf_size - size;
if (!running_slideshow)
if (!iv->running_slideshow)
{
rb->lcd_putsf(0, 2, "image %dx%d", bmp.width, bmp.height);
rb->lcd_update();
@ -235,7 +230,7 @@ int load_image(char *filename, struct image_info *info,
return PLUGIN_OK;
}
int get_image(struct image_info *info, int ds)
static int get_image(struct image_info *info, int ds)
{
struct t_disp* p_disp = &disp[ds]; /* short cut */
@ -270,7 +265,7 @@ int get_image(struct image_info *info, int ds)
buf_images += size;
buf_images_size -= size;
if (!running_slideshow)
if (!iv->running_slideshow)
{
rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height);
rb->lcd_update();
@ -294,3 +289,13 @@ int get_image(struct image_info *info, int ds)
return PLUGIN_OK;
}
const struct image_decoder image_decoder = {
true,
img_mem,
load_image,
get_image,
draw_image_rect,
};
IMGDEC_HEADER

View file

@ -10,12 +10,18 @@
BMPSRCDIR := $(IMGVSRCDIR)/bmp
BMPBUILDDIR := $(IMGVBUILDDIR)/bmp
ROCKS += $(BMPBUILDDIR)/bmp.rock
BMP_SRC := $(call preprocess, $(BMPSRCDIR)/SOURCES)
BMP_OBJ := $(call c2obj, $(BMP_SRC))
# add source files to OTHER_SRC to get automatic dependencies
OTHER_SRC += $(BMP_SRC)
$(BMPBUILDDIR)/bmp.rock: $(BMP_OBJ)
ROCKS += $(BMPBUILDDIR)/bmp.ovl
$(BMPBUILDDIR)/bmp.refmap: $(BMP_OBJ)
$(BMPBUILDDIR)/bmp.link: $(PLUGIN_LDS) $(BMPBUILDDIR)/bmp.refmap
$(BMPBUILDDIR)/bmp.ovl: $(BMP_OBJ)
# special pattern rule for compiling image decoder with extra flags
$(BMPBUILDDIR)/%.o: $(BMPSRCDIR)/%.c $(BMPSRCDIR)/bmp.make
$(SILENT)mkdir -p $(dir $@)
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(IMGDECFLAGS) -c $< -o $@

View file

@ -1,5 +0,0 @@
#define BMP_VIEWER
#define MENU_TITLE "BMP Menu"
#define UNSCALED_IS_AVAILABLE 1
#include "../imageviewer.c"