Author Topic: mViewer - Nspire BMP viewer  (Read 30688 times)

0 Members and 1 Guest are viewing this topic.

SirCmpwn

  • Guest
Re: mViewer - Nspire BMP viewer
« Reply #45 on: December 13, 2010, 10:25:41 pm »
If we control the palette, then my statement is still valid.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: mViewer - Nspire BMP viewer
« Reply #46 on: December 13, 2010, 10:26:14 pm »
No, it isn't. The palette is used to look up color values, of which there are still only 15.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

SirCmpwn

  • Guest
Re: mViewer - Nspire BMP viewer
« Reply #47 on: December 13, 2010, 10:27:25 pm »
Thank you.  So what we can do is change the values of particualr nibbles as the LCD would see them, correct?  We could make 0xF black, for instance.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: mViewer - Nspire BMP viewer
« Reply #48 on: December 13, 2010, 10:29:28 pm »
Right (in 4-bit mode). In 8-bit mode, you can have each of the values 0x00-0xFF correspond to a 15-level grayscale color. This might be useful even if just for the sake of being able to read/write pixels byte-by-byte instead of having to extract nibbles.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

SirCmpwn

  • Guest
Re: mViewer - Nspire BMP viewer
« Reply #49 on: December 13, 2010, 10:30:17 pm »
That could make it more speedy, I guess.

Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: mViewer - Nspire BMP viewer
« Reply #50 on: December 13, 2010, 10:39:00 pm »
That could make it more speedy, I guess.

What do you want to be faster?
My code is allready telling the Nspire to wait! :p

Remember we have 90MHz. ;)



No, it isn't. The palette is used to look up color values, of which there are still only 15.

Ok, the palette may be limited to 15/16 entries.

But... it seems there is a 16bpp mode.
And in this mode, each pixel is supposed to contain directly a 16-bit RGB/BGR color value and not a palette index.

Which would mean we can have 256-level grayscale ? . . . ;)
TI-Planet co-admin.

SirCmpwn

  • Guest
Re: mViewer - Nspire BMP viewer
« Reply #51 on: December 13, 2010, 10:40:21 pm »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: mViewer - Nspire BMP viewer
« Reply #52 on: December 13, 2010, 10:40:43 pm »
The palette contains 16-bit color values, anyway (and is limited to 256 entries). The upper 4 bits of the R portion of the value determines the grayscale level.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: mViewer - Nspire BMP viewer
« Reply #53 on: December 13, 2010, 11:00:32 pm »
Excuse the double post, I have some important info here.

critor, you say your code tells the Nspire to wait, but it doesn't do that during actual bitmap display. The code seems to run rather slowly. I'd like to suggest an alternative dispBufIMG routine that uses fixed point and less calculations in the innermost loop (may require tweaking to work, this particular one hasn't been tested):
Code: [Select]
void dispBufIMG(unsigned char* buf, int xoff, int yoff, char* img, int width, int height, float inc)
{
int dwidth = width<<16, dheight = height<<16;
int data_x = 0, data_y = 0;
unsigned int x, y;
int fixedinc = inc*(1<<16);
int i, j;
if(xoff < 0){
data_x = -xoff;
xoff = 0;
}
if(yoff < 0){
data_y = -yoff;
yoff = 0;
}
char* k;
for(j=data_y, y=yoff; j < dheight && y < SCREEN_HEIGHT; j += fixedinc, y++)
for(i=data_x, x=xoff, k=img+width*(j>>16); i < dwidth && x < SCREEN_WIDTH; i += fixedinc, x++)
setBufPixel(buf, x, y, k[i>>16]);
}
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: mViewer - Nspire BMP viewer
« Reply #54 on: December 14, 2010, 06:00:48 am »
Thank you calc84maniac.
I'm going to try.

Edit: got another idea to speed up things even more (although speed doesn't seem to be a problem here).
« Last Edit: December 14, 2010, 08:39:59 am by critor »
TI-Planet co-admin.

Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: mViewer - Nspire BMP viewer
« Reply #55 on: December 14, 2010, 06:18:29 pm »
Forget about mViewer and its 16 grayscale levels (4-bits).

The last build of mViewer is now able to display your bitmaps in not less than 31 different grayscale levels! (8-bits)

And guess what? While viewing the image, it as fast as the last public binary.


It was quite hard to take a photo.



Note: it looks much better without an APN.
TI-Planet co-admin.

SirCmpwn

  • Guest
Re: mViewer - Nspire BMP viewer
« Reply #56 on: December 14, 2010, 06:24:13 pm »
What?!?  Does that same link on TI-Bank work for the latest version?

Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: mViewer - Nspire BMP viewer
« Reply #57 on: December 14, 2010, 06:34:51 pm »
What?!?  Does that same link on TI-Bank work for the latest version?

It's just worked for the 1st time a hour ago.
This special version is not pubic for now.
It needs some more testing/debugging.
The internal buffered data was changed from a 4-bits to 16-bits.


But when I release it, the same link is going to work. And you'going to be informed first! :p

And it should even be faster. the screen refresh code is now only copying the screen content 1 time instead of 2, although it still uses buffering.


Guess what... the Nspire is wonderfull!!!
(why did we have to wait 4 years for that?... silly TI!!!)
« Last Edit: December 14, 2010, 06:35:49 pm by critor »
TI-Planet co-admin.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: mViewer - Nspire BMP viewer
« Reply #58 on: December 14, 2010, 06:41:29 pm »
This viewer is truly amazing! Excellent job, critor! :)

I was wondering, in the future, would it be possible to add support for other image file types?


Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: mViewer - Nspire BMP viewer
« Reply #59 on: December 14, 2010, 07:03:59 pm »
I was wondering, in the future, would it be possible to add support for other image file types?


Yes it would be possible.
We just need the code to decompress those images data to a raw bitmap.

JPEG/PNG/GIF support should be possible.
I think PNG is the easiest format and should be supported first.
JPEG decompression is much harder...
And GIF files can have multiple layers of various dimensions, layers which can cross the canvas border.
TI-Planet co-admin.