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: How to use RAM-G directly - upload RAW array  (Read 6858 times)

korstiaan

  • Newbie
  • *
  • Posts: 14
    • View Profile
How to use RAM-G directly - upload RAW array
« on: August 26, 2020, 01:57:12 PM »

Hi,

Based on BRT_AN_025 Beta + BT81X

I want to upload a RAW image directly in the RAM-G and then display it.
As a test I'm using a simple 100x100px all black (or white) pixels.
That is a RAW array of 10000x 0x00 in L8.

So I first upload the 10000 bytes like this:

Code: [Select]
uint8_t *array;

    array = malloc(10000);
    for (uint16_t i = 0; i < 10000; i++) {
        array[i] = 0x00; // 0x00 = black, 0xff = white
    }

EVE_LIB_WriteDataToRAMG(array, 10000, 0);
free(array);

and then I display the bitmap like this:

Code: [Select]
    EVE_LIB_BeginCoProList();
    EVE_CMD_DLSTART();
    EVE_CLEAR_COLOR_RGB(0, 0, 0);
    EVE_CLEAR(1, 1, 1);

    EVE_COLOR_RGB(255, 255, 255);
    EVE_BITMAP_SOURCE(0);
    EVE_BITMAP_LAYOUT(EVE_FORMAT_L8, 100 * 100, 100);
    EVE_BITMAP_SIZE(EVE_FILTER_NEAREST, EVE_WRAP_BORDER, EVE_WRAP_BORDER, 100, 100);
    EVE_BEGIN(EVE_BEGIN_BITMAPS);
    EVE_VERTEX2F(650 * 16, 205 * 16);
    EVE_END();

    EVE_DISPLAY();
    EVE_CMD_SWAP();
    EVE_LIB_EndCoProList();
    EVE_LIB_AwaitCoProEmpty();


But I get a scrambled bitmap and not a solid black (white) one.

What am I doing wrong?

Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: How to use RAM-G directly - upload RAW array
« Reply #1 on: August 26, 2020, 02:34:40 PM »

Hi,

Your stride seems wrong here, L8 uses one byte per pixel and so just 100 instead of 100*100. Stride is for the bytes per line rather than in total.

It's easier to use Cmd_SetBitmap as this sets the BITMAP_SIZE_H and BITMAP_LAYOUT_H high bits of the values as well (these are used to allow values more than 511 but should always be written anyway even if 0).    It also means fewer lines of code and less chance of error. It creates the correct entries for you equivalent to setting the size, layout and format yourself.

EVE_CMD_SETBITMAP(0, EVE_FORMAT_L8, 100, 100);

Best Regards, BRT Community

Logged

korstiaan

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: How to use RAM-G directly - upload RAW array
« Reply #2 on: August 26, 2020, 02:56:41 PM »


Oh yes, thanks!  ;D

1. But in my example with L8, what is the start address for the next image I want to store in my RAM-G? Is it 10000?
2. If I want to use for example L2 for that 100px x 100px, is the end address then 2500? (I use EVE Asset builder to help me)

Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: How to use RAM-G directly - upload RAW array
« Reply #3 on: August 27, 2020, 10:59:23 AM »

Hi,

Yes, you can start the new image on the next 4-byte aligned boundary after the last image. For L8 the number of bytes will be equal to height x stride (where stride will be equal to width for L8)

L2 uses 2 bits per pixel and so each byte will have 4 pixels worth of data. It may be padded as stride is a multiple of whole bytes and so worth checking the comment at the very top of your rawh file which is generated as this will confirm the values for each image you convert.
e.g. /*('file properties: ', 'resolution ', 184, 'x', 185, 'format ', 'L2', 'stride ', 46, ' total size ', 8510)*/

Best Regards,
BRT Community



Logged