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: displaying compressed png  (Read 8871 times)

DAVOSS

  • Newbie
  • *
  • Posts: 3
    • View Profile
displaying compressed png
« on: February 17, 2021, 04:08:33 PM »

Hello everyone.
I've got a project on FT811 5' display controlled with arduino nano and micro SD card. I'm using GD23Z library.
Main purpose of this project is to display numbers from 0 to 99 (each digit must be height almost as the screen is). I would like to avoid loading each digit from micro sd seperatly when i need it mainly because change needs to be quick without any visible delay.
I see 3 ways.
1. using seperate SPI pins for micro sd reader and screen to speed up loading process
2. loading (to display's RAM) small numbers at once, lets say 100x50 resolutions and zooming it with cmd_scale function.
3. try to load all numbers (460x300 resolution) to display's RAM compressed with EVE compressing tool ( i was thinking about PALETTE8, index.bin) and then just decompress it when i need it.

I like 3rd option the most. I'm trying to make it work for 2 days already. I've compressed png file which contains numer 3 with EVE Asset builder v2.1.0 choosing output format as PALETTE8 and checked compressed box. In result i received file 3'_index.bin which i loaded to micro sd card. Now i'm trying to make it work with the following sequence.

 GD.begin();
 GD.cmd_inflate(0);
 GD.load("3'_index.bin");

and then in loop


GD.Begin(BITMAPS);
GD.Vertex2ii(190, 180,0);
 GD.swap();

I'm pretty sure im missing some commands

In result i receive something like this
https://imgur.com/IZPozmv

and i should receive sth like this
https://imgur.com/DRM7MdO


Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: displaying compressed png
« Reply #1 on: February 20, 2021, 01:43:06 PM »

I fished a set of number images like yours out of the internet and scaled them down to 328x456.
At this resolution only two can be displayed at once.
One image needs 299136 bytes in RGB565 format, so two need 598272 bytes which already is more than half
of RAM_G.

Using zlib compression on the FT811 is not possible for this purpose as CMD_INFLATE can not work with data that already is in RAM_G.
That leaves CMD_LOADIMAGE which could be used for this by calling it with the MEDIAFIFO option using CMD_MEDIAFIFO to setup the MEDIAFIFO at the size and position of an already stored .jpg in RAM_G.

Why .jpg and not .png?
Because .png with alpha channel is way larger than saving the same image as .jpg with 80%.
There is only 440kB of RAM_G left.
Also .png decodes a lot slower than .jpg which might result in odd visuals.

So if this is possible still depends on the actual resolution used and how compressible the images are.


My advice is, toss away the FT811 and get a display with a BT815.
Then you can use ASTC compressed images directly which are a lot smaller, even with alpha-channel.

Logged

ddv2005

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: displaying compressed png
« Reply #2 on: February 22, 2021, 02:50:03 PM »

GD.begin();
 GD.cmd_inflate(0);
 GD.load("3'_index.bin");

and then in loop


GD.Begin(BITMAPS);
GD.Vertex2ii(190, 180,0);
 GD.swap();

I think that your sequence is wrong. cmd_inflate just decompress data but does not set any bitmap parameters like layout, size and etc. You have to use Cmd_SetBitmap+PALETTE_SOURCE to set bitmap properties after cmd_inflate but I have no idea what parameters for PALETTE8 because it use indexes.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: displaying compressed png
« Reply #3 on: February 22, 2021, 03:33:02 PM »

Hi,

Yes there is normally an index and a look up table file for paletted 8. I'm not sure how the GD library displays these and what underlying code it has but you need some additional blending too in order to display paletted 8. Please see section 4.7 in the programmers guide.
https://brtchip.com/wp-content/uploads/Support/Documentation/Programming_Guides/ICs/EVE/FT81X_Series_Programmer_Guide.pdf

Due to the 1M of RAM, you may be able to use smaller types of image (such as L1 or L2) to avoid loading them on the fly. But these would make black and white or grayscale characters rather than your more complex ones. You can make them a colour though the COLOR_RGB command and maybe even add some extra effects using the graphics features of EVE however.

Best Regards,
BRT Community
« Last Edit: February 22, 2021, 03:59:01 PM by BRT Community »
Logged

DAVOSS

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: displaying compressed png
« Reply #4 on: February 25, 2021, 03:01:18 PM »

Thanks for your help everyone. I need png for trasnparent background but i managed to load small size numbers and just rescale it. I've got diferent problem now. I think i recalbiratet touch screen somehow, i was messing with EEPROM. GD.input.y is giving me proper reading but GD.input.x is giving my large number like 3000, 16000. Can i calibrate it somehow with GD23Z library ?
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: displaying compressed png
« Reply #5 on: February 26, 2021, 05:04:32 PM »

Hi,

It may depend on which version of the library you use but the GD2 library has a function to call the calibrate command,

void GDClass::self_calibrate(void) {
cmd_dlstart();
Clear();
cmd_text(w / 2, h / 2, 30, OPT_CENTER, "please tap on the dot");
cmd_calibrate();
finish();
cmd_loadidentity();
cmd_dlstart();
GDTR.flush();
}

Best Regards, BRT Community
Logged

DAVOSS

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: displaying compressed png
« Reply #6 on: March 04, 2021, 02:11:11 PM »

Thank you it helped !
Logged