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: Proper way to set up and display multiple bitmaps in one DL  (Read 8165 times)

rmand

  • Newbie
  • *
  • Posts: 11
    • View Profile


I'm able to display display multiple image/bitmaps as long as each image is set up with HANDLE, SOURCE, etc immediately prior to display.

If I try to set up multiple bitmaps parameters in advance, and then add a bitmap using VERTEX2F, I get a corrupted screen/display.

Below is an example of what does NOT work:

Note, the image data is already loaded into RAM and imageTable array contains valid bitmap attributes.


Code: [Select]
char handles[] = { 8,9 };
uint32_t addresses[] = { ramBitmapAddress1,ramBitmapAddress2};


       int count = 1; // if count == sizeof(handles) the display gets corrupted

for (int i = 0; i < sizeof(handles); i++) { 
App_WrCoCmd_Buffer(phost, BITMAP_HANDLE(handles[i]));
App_WrCoCmd_Buffer(phost, BITMAP_SOURCE(addresses[i]);
App_WrCoCmd_Buffer(phost, BITMAP_LAYOUT(L1, imageTable[i]->Stride, imageTable[i]->Height));
App_WrCoCmd_Buffer(phost, BITMAP_SIZE(NEAREST, BORDER, BORDER, imageTable[i]->Width, imageTable[i]->Height));
}

//Place the image
App_WrCoCmd_Buffer(phost, BEGIN(BITMAPS)); // start drawing bitmaps
App_WrCoCmd_Buffer(phost, COLOR_RGB(0,255,0));
App_WrCoCmd_Buffer(phost, VERTEX2F(685 * 16, 380 * 16, 8, 0));
App_WrCoCmd_Buffer(phost, END());



What is the correct way of doing this?  It seems inefficient to have to set up the bitmap attributes every time it's being used.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #1 on: July 18, 2022, 03:49:57 PM »

Hello,

It is worth considering the CMD_SETBITMAP as this makes it easier to set up your bitmaps and is easier to use than the individual commands.

You can use a SetBitmap command just before the vertex

   BEGIN(BITMAPS);
   CMD_SETBITMAP(0, L2, 300, 225);
   VERTEX2F(0,0);
   CMD_SETBITMAP(40000, L2, 300, 225);
   VERTEX2F(100*16,100*16);

You can also set the bitmaps up in a display list beforehand and you can then use them later on. for this you can create a display list with DLSTART at the start and DISPLAY  SWAP at the end.
{
        CMD_DLSTART();
   CLEAR_COLOR_RGB(0, 0, 0);
   CLEAR(1,1,1);

   BITMAP_HANDLE(0);
   CMD_SETBITMAP(0, L2, 300, 225);
   BITMAP_HANDLE(1);
   CMD_SETBITMAP(40000, L2, 300, 225);

   DISPLAY();
   CMD_SWAP();
}

// in the new screen where you want to use them:
   BEGIN(BITMAPS);
   VERTEX2II(0,0,0,0); // handle 0
   VERTEX2II(100,100,1,0); // handle 1

Best Regards, BRT Community
« Last Edit: July 18, 2022, 04:18:54 PM by BRT Community »
Logged

Kaetemi

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #2 on: July 19, 2022, 07:19:43 PM »

Below is an example of what does NOT work:

You're missing `BITMAP_HANDLE` before the `VERTEX2F` call. The display list is a state machine, so the draw depends on the state that's set. The handle is used to point to one of 32 bitmap states, which persist across frames. And don't forget `DISPLAY` at the end to end the display list, as it may contain garbage.

Also, you may be missing `BITMAP_SIZE_H` and `BITMAP_LAYOUT_H` calls, their previous state may contain garbage as well.

I recommend using the `EVE_CoDl_` convenience calls from HAL, such as `EVE_CoDl_bitmapLayout`, instead of App_WrCoCmd_Buffer etc, as they simplify compatibility and reduce mistakes. (e.g. `EVE_CoDl_vertex2f_4` includes logic to automatically switch vertex format if your coordinates are out of range, and `EVE_CoDl_vertexFormat` deduplicates redundant state change calls.)
Logged

rmand

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #3 on: August 16, 2022, 05:53:52 PM »

Thank you for your help!
Looks like there were two issues.

1) The examples and programming guide makes heavy use of direct to DL commands.  So I was setting the handle in the DL but the bitmap info in the CO CMD queue.
2) DISPLAY() at the of the DL was required otherwise the bitmaps would get chopped or shrunk depending on the garbage passed the end of the list in DL RAM.

Logged

fr3ud

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #4 on: October 19, 2022, 06:39:05 PM »

May I ask if there is a limitation on the number of bitmaps? I'm trying to do the same, it works now with the info in this topic, but Im limited to 4 pictures making 304x304 loaded in flash (RGBA_ASTC_8x8_KHR)
Am I hitting the max bandwidth of the memory?
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #5 on: October 21, 2022, 01:40:47 PM »

Hello,

You could have a large number of images in flash itself but if you display many images on the same screen at the same time, you may reach a limit due to the bandwidth.

You could try copying some of them to RAM_G and displaying from there which will reduce the amount of data read from the flash itself in real time,

Best Regards, BRT Community 
Logged

fr3ud

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #6 on: October 22, 2022, 09:29:25 AM »

Thank you for this answer
How would you manage this for "static" background images that are memcopy and then appended back?
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #7 on: October 25, 2022, 11:14:55 AM »

Hi,

As one possible way, if you use an image in an appended section, you could use a structure or variables to record where the image is in flash along with the size etc, and store this along with the details of the associated static section (e.g. the address and length in RAM_G of your static code).   So you would have a structure with properties of the instructions to be appended as well as the image(s) used.

Then, just before you begin to create the final display list, you could have a section of code which does the copy from flash to RAM_G if the static sections used have any associated image.

Best Regards, BRT Community

Logged