BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: PALETTED4444 byte count  (Read 8588 times)

obones

  • Newbie
  • *
  • Posts: 9
    • View Profile
PALETTED4444 byte count
« on: September 22, 2021, 11:00:03 AM »

I'm decoding a 64x64 PNG file with CMD_LOADIMAGE and this gives me a PALETTED4444 image.
Looking at page 63 in BRT_000225, I see that it uses 16 bits, 4 for each components of the pixel, which matches the name of that format.
As a result, I give 64*2=128 as the linestride value in the BITMAP_LAYOUT command.
But this gives me a scaled down by 2 bitmap on the TFT.

I thus looked around the datasheet, and at page 60 it says that PALETTED4444 is using 8 bits per pixel which goes against what's shown at page 63. So what's the real value to use as the multiplier for linestride? 1 or 2?

And what is the memory layout for such a bitmap? With ARGB4, it's easy: 64*64*2 = 8192 bytes. But how do I know how much RAM is consumed by a PALETTED4444 image created by CMD_LOADIMAGE?
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: PALETTED4444 byte count
« Reply #1 on: September 24, 2021, 10:26:41 AM »

Hello,

On Paletted 4444 the stride would be 64 as it will have one byte per pixel.

The Paletted formats differ from the ARGB4444 in that the ARGB4444 have 2 bytes per pixel with the alpha and RGB values (4-bits each). The Paletted format instead has a byte per pixel which then refers to an index in the color palette (see the LUT (Look Up Table)  file which is also created).

You therefore get better color depth but only with a limited range of colours.

You'll probably find that the paletted 4 is just over half the size of ARGB4 because it uses this one byte per pixel plus a bit extra for the LUT.

We have a command GETPROPS which can check the next available free address after the loadimage is completed (on a PNG only) and so you can subtract the starting address (which you specified in LOADIMAGE) from your next free address returned by GETPROPS to get the size. If you use BT817/8 we also have CMD_GETPTR which does this.
You can find one example in section 7.3 below of GETPROPS
https://ftdichip.com/wp-content/uploads/2020/07/BRT_AN_014_FT81X_Simple_PIC_Library_Examples.pdf

Best Regards, BRT Community


Logged

obones

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: PALETTED4444 byte count
« Reply #2 on: September 24, 2021, 04:11:40 PM »

Thanks, that clarifies the situation. I believe that page 63 of the datasheet should be reviewed, it gives a wrong sense of what the memory usage would be.
Logged