FS#6321 - Universal Image Viewer

Attached to Project: Rockbox
Opened by Geoff Stokes (iwantanimac) - Sunday, 12 November 2006, 14:09 GMT
Last edited by Teruaki Kawashima (teru) - Sunday, 21 November 2010, 14:00 GMT
Task Type Patches
Category Plugins
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.4
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This would be a pretty much universal image viewer. Perhaps even to replace the jpeg plugin. bmp support already exists, as there is a plugin for it, but other formats would be good, too.

The plugin should;
- Detect image format before loading (If it cannot be identified by file extension, it should check for header data if it's not recognised)
- Be able to display the following formats:
- PNG []
- Transparency could be an issue, i guess you would just choose what background to have displayed, or not enable the alpha channel. (Not that i know how you would go about this...) - similar for GIFs
- GIF [ - I think that's ok]
- Would animated GIFs be possible (As an animation)? Otherwise, allow cycling through frames.
- BMP (Already implemented with the BMPviewer plugin with BMP Resize - #5697}
- Possibly JPG, replacing the current jpeg plugin (If it's good enough), or becoming part of the jpeg plugin.
- Resize images (Like the way the jpeg plugin does it, not like BMP Resize, as this looks horrible)
- Cycle through images of ALL compatible formats, and have slideshow function (like JPEG plugin)
- Anything else appropriate (And most of the features already present in the jpeg plugin)

Comments, contributions or anything else would be awesome, as i think this would be excellent for the big 4 image formats to be supported. Hopefully most targets have the processing power to decode these formats quick enough!
This task depends upon

Closed by  Teruaki Kawashima (teru)
Sunday, 21 November 2010, 14:00 GMT
Reason for closing:  Accepted
Additional comments about closing:  committed in r28626.
Comment by Geoff Stokes (iwantanimac) - Sunday, 12 November 2006, 14:10 GMT
aww, it didn't keep my whitespace... grr...
PNG and the next line are related, as are GIF and the line under that.

As i said, if anyone can contribute or help, that'd be great.
Comment by Eli Sherer (elisherer) - Friday, 17 November 2006, 10:17 GMT
I've already implemented GIF with  FS#3037 
and I saw you commented there...
Animation is tough cause you need to keep in the memory every frame
(or changes of frame like the file itself keeps)
but i tried to implement animation in this one...
Comment by Thomas Martitz (kugel.) - Sunday, 14 October 2007, 14:53 GMT
I highly support this request. I'd like to see PNG support particulary!
Comment by Johannes Schwarz (Ubuntuxer) - Tuesday, 27 October 2009, 16:19 GMT
Meanwhile Christophe Gouiran wrote a PNG plugin ( FS#9493 ), so the aim of this task should be to merge the JPEG and the PNG plugins to a single image viewer.
BMP decoding support already exists and Michael Ignatiev is working on a BMP viewer. ( FS#10535 ) In my opionion it would be better to focus on a universal image viewer.

The aim should be that Rockbox also supports PNG album art, but this is a another task...
Comment by Teruaki Kawashima (teru) - Wednesday, 23 December 2009, 08:03 GMT
this patch merges user intereface part of code in JPEG Viewer and PNG Viewer. note that they are still separate plugin.
this aims for:
* make it simpler to add new image viewer (bmp, gif ...) with same ui as JPEG.
* get rid of maintaining two almost same code.
* probably first step to merge these viewer plugins to one image viewer plugin.
Comment by Thomas Martitz (kugel.) - Wednesday, 23 December 2009, 08:07 GMT
Nice! Have you thought about putting it into the pluginlib instead?

Also, there's a image viewer with could potentially use it: ppmviewer.

It's probably a good idea to keep the plugins separate, otherwise you need black magic for managing the memory.
Comment by Tomer Shalev (tomers) - Wednesday, 23 December 2009, 08:23 GMT
teru: Can you please also update the manual accordingly?
Comment by Teruaki Kawashima (teru) - Wednesday, 23 December 2009, 08:53 GMT
I haven't thought that idea. but I think this implementation is not likely to suit for that.
I made this so that files in jpeg/ and png/ look more or less a "image codec" and put all stuff needed for a plugin to ui code.
yeah, ppmviewer could use this.

I don't think i changed something that needs to change manual.
Comment by Thomas Martitz (kugel.) - Wednesday, 23 December 2009, 08:55 GMT

>> I haven't thought that idea. but I think this implementation is not likely to suit for that.

Can you explain that? Isn't the UI part API which the plugins call? That perfectly suits to the pluginlib.
Comment by Teruaki Kawashima (teru) - Wednesday, 23 December 2009, 09:27 GMT
below is abstract of function calls.
i moved functions plugin_start, load_and_show, scroll_bmp to imageviewer_ui.c as they are common and left load_image, get_image, draw_image_part in jpeg.c/png.c as they are specific.
so, imageviewer_ui.c is core part and it calls functions in jpeg/png when load, decode/resize, or display image.

plugin_start() {
__/* initialize file list and get plugin buffer etc. */
__/* deinitialize. */

load_and_show() {
__load_image() /* load file from disk */
__while() {
____get_image() /* decode/resize image to display */
____draw_image_part() /* display image */
____scroll_bmp() /* handle button */
Comment by Teruaki Kawashima (teru) - Friday, 15 January 2010, 14:35 GMT
Update patch.
* moved jpeg/ directory and png/ directory to under imageviewer/ directory.
I'm thinking to merge the two plugins to single image viewer later.

before apply the patch, it is needed to create apps/plugins/imageviewer/ direcotry and move both apps/plugins/jpeg/ and apps/plugins/png/ under it manually.
e.g. (if using svn):
$ svn mkdir apps/plugins/imageviewer
$ svn mv apps/plugins/jpeg/ apps/plugins/png/ apps/plugins/imageviewer
Comment by Teruaki Kawashima (teru) - Thursday, 21 January 2010, 02:59 GMT
Here is my work for universal image viewer. this is test version and may contain problems to freeze or crash the player or might not work at all especially on lowmem targets.
this includes adapted version of  FS#10535 .
tested on gigabeat X.
this uses loadable image decoder borrowing code from lib/overlay.c
with this patch, some files will be created - imageviewer.rock, imageviewer_bmp.ovl, imageviewer_jpeg.ovl, imageviewer_png.ovl (only for color targets still).
it should work like following.
when a supported image file (bmp, jpeg, or png) is played, imageviewer.rock is launched as usual.
create list of names of supported image in current directory. this is same as current jpeg/png viewer.
then the plugin determine type of the image (one of bmp, jpeg, png) by it's extension and load appropriate decoder (imageviewer_X.ovl where X is bmp, jpeg, or png).
- the decoder is loaded at the end of the plugin buffer.
the decoder will load/decode or resize/display the image on demand.
when the image is changed, another decoder is loaded if needed (e.g. when chaged to b.jpeg from a.bmp).

on the simulator, all decoders are linked to imageviewer.rock and loading decoder at runtime is not done.

some random thoughts:
* need to check how much memory is used for imageviewer.rock, grey buffer and decoder, and ensure they don't conflict each other.
* and maybe compare to current jpeg.rock/png.rock.
* consider a way to exclude png entry from viewers.config for non color targets.
- maybe add "png,imageviewer_png" instead of "png,imageviewer" and strip _png while buildzip?
* no idea.
Comment by Teruaki Kawashima (teru) - Friday, 19 February 2010, 15:39 GMT
synced to r24774.
Comment by Teruaki Kawashima (teru) - Monday, 17 May 2010, 14:39 GMT

Edit: replace the patch. don't use previous imageviewer.3.patch.
Comment by Teruaki Kawashima (teru) - Friday, 27 August 2010, 13:40 GMT

this works to me but i haven't solved 1 issue yet - png entry is included to viewers.config even for non color targets while png is not supported yet.
Comment by Teruaki Kawashima (teru) - Tuesday, 21 September 2010, 13:21 GMT
Update patch.
use lc_open to load decoder and do loading decoder on the simulator.
Comment by Teruaki Kawashima (teru) - Sunday, 26 September 2010, 14:59 GMT
update patch.
*preprocess viewers.config to exclude unsupported types.
*remove unneeded rb->cpucache_invalidate(); (thanks to kugel).
Comment by Teruaki Kawashima (teru) - Monday, 01 November 2010, 14:47 GMT
Comment by Teruaki Kawashima (teru) - Monday, 01 November 2010, 15:28 GMT
fixed typo...
Comment by Teruaki Kawashima (teru) - Tuesday, 02 November 2010, 13:32 GMT
third try.. i should have tested before apploding patch.
i tested this and worked on gigabeat x30 and ipodmini1g.
Comment by Michael Stummvoll (Stummi) - Monday, 08 November 2010, 19:36 GMT
Works fine on fuze v2
Comment by Teruaki Kawashima (teru) - Wednesday, 10 November 2010, 11:36 GMT
Thank you for testing.