CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: gameblabla on January 09, 2017, 03:01:29 AM

Title: Simple Image Viewer
Post by: gameblabla on January 09, 2017, 03:01:29 AM
Here's a simple image viewer for the TI Nspire CX & (maybe) Monochrome nspires.

(https://tiplanet.org/modules/archives/captures/1483930604imgviewer_scr1.png)

It supports PNG, BMP, and JPEG files. (Baseline & Progressive)
It's pretty fast, fairly small and has a codebase that is easier to read than mViewerCX, which is absolutely monstrous...
However it struggles with big images files and there are some corruptions for BMP files.
So if you want to load huge image files on your nspire, stick with mViewerCX.

For big images, switch to cropping mode with the DEL key and it will benefit from a smoother framerate, much better than mViewerCX.
However, you can't zoom in/out in "cropping" mode, unlike the default "scaling" mode.
It also uses my explorer browser, which is much simpler to use unlike the one in mViewerCX which is horrible to use, seriously.

I originally made this so i can watch my pr0nographic images on my calc and because i did not enjoy using mViewerCX
with its slow framerate and awful interface.

Source code is here :
https://github.com/gameblabla/simpleimageviewer (https://github.com/gameblabla/simpleimageviewer)

Spoiler

Here's an OS version for ControlX 4.3.6 (Deprecated, slower than ndless version) :
https://codewalr.us/index.php?topic=1820.msg50693#msg50693 (https://codewalr.us/index.php?topic=1820.msg50693#msg50693)
[close]

Video of it running :
https://gameblabla.nl/files/imgviewer_speedcompar.mp4 (https://gameblabla.nl/files/imgviewer_speedcompar.mp4)

Btw, this uses a modified version of n2DLib and OK_JPG as well as LodePNG.
Title: Re: Simple Image Viewer
Post by: Yuki on January 09, 2017, 03:19:21 AM
ohai it's me as the example~

Anyway, nice.
Title: Re: Simple Image Viewer
Post by: gameblabla on January 09, 2017, 03:38:45 AM
Quote from: Juju on January 09, 2017, 03:19:21 AM
ohai it's me as the example~
Yeah... my computer is filled with pr0n and this was the only rare image that was not pr0nographic on my PC.
glad you don't mind

Also, i would be happy if anyone could take a look at the cooode and tell me what could be possibly improved.
Title: Re: Simple Image Viewer
Post by: p2 on January 09, 2017, 11:35:03 AM
having ONLY pron on your pc already sounds weird...
but it sounds even worse, having only pron aaaand pics of Juju on your PC :ninja:
I mean... WHY??  :ninja:

anyways, nice work, can you give us a gof of it and maybe some info on the speed and size? :)
Title: Re: Simple Image Viewer
Post by: Snektron on January 09, 2017, 11:38:22 AM
(maybe the pron and the pictures of juju are on his pc for the same reason  O.O)
Title: Re: Simple Image Viewer
Post by: p2 on January 09, 2017, 11:41:19 AM
exactly what I was thinking...  :ninja:

inb4 kotu revealing Juju's and gameblabla's secret relationship....
Title: Re: Simple Image Viewer
Post by: Yuki on January 09, 2017, 07:54:56 PM
Haaa, I don't wanna know D:
Title: Re: Simple Image Viewer
Post by: p4nix on January 09, 2017, 08:00:19 PM
Maybe you would switch your mind if you knew how @gameblabla looks like, please note it's only a identikit picture ;)
(https://img.codewalr.us/gameblabla.png)
Title: Re: Simple Image Viewer
Post by: gameblabla on January 10, 2017, 04:25:34 PM
I look nothing like this p4nix...

Also, for the kicks, i made an OS version based on Dummy OS.
This version requires the very latest version of ControlX installed (https://tiplanet.org/forum/download/file.php?id=3076&sid=8aaba8f5e9152df4b31138a671264a12), as version 3.4.5 has a bug that prevents Dummy OS from running.

I compared the Ndless version and the OS version and here's the verdict :
https://gameblabla.nl/files/imgviewer_speedcompar.mp4 (https://gameblabla.nl/files/imgviewer_speedcompar.mp4)

The OS version, which has no overhead, more memory available, is twice to three slower than the TI version !
Not only that, it's very unstable and it will refuse to run if the image is more than 2MB...
Why is that ? Stack issues ? Missing code to turn it in fast mode ? Underclocked cpu ?
Or even something else entirely ?
Because it seems that it does not use the full 64Mb...

Btw, the os version is flickering because it has no buffering, i hope this will figured out because i don't have access to malloc.
(maybe it is in boot1 but where ?)

Oh, no way i would be interested in juju, he's too hairy and beardy.
Title: Re: Simple Image Viewer
Post by: p2 on January 10, 2017, 04:31:30 PM
that beard sure is worth zooming in  :thumbsup:
but it wurts to see you use inverted controls D:

anyways the speed is still impressive :)
I wonder how much the speed would drop for multi-layer games... O.O
what language is used for the CX CAS again...? (I happen to have that one, too)
Title: Re: Simple Image Viewer
Post by: gameblabla on January 10, 2017, 04:36:23 PM
Quote from: p2 on January 10, 2017, 04:31:30 PMthat beard sure is worth zooming in  :thumbsup:
worth the wait

Quote from: p2 on January 10, 2017, 04:31:30 PM
anyways the speed is still impressive :)
*
I disagree, the OS version is fricking horrible...
If anyone wants to take a look at the dummy os version, it's here :
https://github.com/gameblabla/simpleimageviewer/tree/dummyos (https://github.com/gameblabla/simpleimageviewer/tree/dummyos)

Quote from: p2 on January 10, 2017, 04:31:30 PM
I wonder how much the speed would drop for multi-layer games... O.O
what language is used for the CX CAS again...? (I happen to have that one, too)
It's entirely programmed in C here with the GCC toolchain.
Of course, this only works with Ndless or ControlX.
Title: Re: Simple Image Viewer
Post by: p2 on January 10, 2017, 04:38:31 PM
ugh, havng to learn C first... D:

I still like it, even if you think its too slow xD
Fot an image viewer, it's perfect :)
Title: Re: Simple Image Viewer
Post by: gameblabla on May 26, 2018, 02:06:35 AM
Erm...
So back to TI-nspire dev now, somewhat.

I found another Jpeg decoder called OK_JPG. Although twice as large as Tiny JPEG Decoder, this one supports Progressive JPEGs, which are becoming more common.
In addition to that, the new lcd blit api is now used, which means it should work better on newer Nspires as well as older calcs.
A bug with PNG files has also been fixed.

Give it a try, download is at the first post.

I also have plans to add SVG support. (fairly basic support)