This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Color problems in Glib of StarterWare



Hi all,

After researching a lot in graphic library of StarterWare, I found that there may have some problems in color order.

We can see that all color definitons (in file glib.h) are defined in R-G-B order. For example:

#define ClrBlue 0x000000FF
#define ClrLime 0x0000FF00
#define ClrRed  0x00FF0000

C image array (which are created by pnmtoc tool as instructed at http://processors.wiki.ti.com/index.php/StarterWare_Graphics#Porting_StellarisWare_graphics_application_to_StarterWare) are in R-G-B order too.

Besides that, LCD contronller desired RGB data for 12-, 16-, 24- BPP modes.(AM335x Technical Reference Manual p.1234).

However, graphic functions use B-G-R order to draw its components.

Ex: In GrOffScreen24BPPPixelDrawMultiple function (offscr24bpp.c):

...

case 16:
{
unsigned short pixColor = 0; /* 16bpp */

pucData++;
while(lCount--)
{
pixColor = *(pucData+1);
pixColor |= (*(pucData)) << 8;

*pucPtr++ = (pixColor & 0x1F) << 3; /* Blue */ 
*pucPtr++ = (pixColor & 0x07E0) >> 3; /* Green */ 
*pucPtr++ = (pixColor & 0x0000F800) >> 8; /* Red */ 
*pucPtr++ = 0x0; /* Alpha */

pucData += 2;
}
break;
}
case 32: /* 24bpp with 1-byte hole */
{
//pucData++;
while(lCount--)
{
*pucPtr++ = *(pucData+3);
*pucPtr++ = *(pucData+2);
*pucPtr++ = *(pucData+1);
*pucPtr++ = *(pucData+0);

pucData += 4;
}
break;
}

I think these code will change pixel data from RGB order to BGR order!

Let me know if I was wrong!

Best regards,

TinND


  • Hi all,

    Is there anyone know how to deal with this problem?

    Best regards,

    TinND

  • Hi TinND,

                   I see that the order is reversed to take care of endianness. Actually AM335x EVM and EVM-SK uses 24bpp LCD and we are able to get the proper colors on LCD as we wanted.

                Are you using 16bpp or 24bpp?

    Regards

    Baskaran

  • Hi Baskaran,

    I used 24bpp mode but BeagleBone LCD 3.5" cape use 16RGB interface. However, I think the problem is not lie in my hardware because of two following reasons:

    1. I reconfigured LCD pinmux correctly to use only 16 LCD data pin and connected them to LCD in correct order.

    2. I tried to reconfigure raster example in evmskAM335x folder and I had the proper colors on my LCD.

    I do not want to change my harware or TI's glib code so can you tell me how to change endian format of LCD driver? 

    Best regards,

    TinND

  • Hi TinND,

                   In grlib the different files offscr1bpp.c, offscr4bpp.c, offscr8bpp.c, offscr16bpp.c and offscr24bpp.c corresponds to different LCD drivers for 1bpp,4bpp,8bpp,16bpp and 24 bpp respectively.

                   In your case you are using 16bpp LCD, so you need to use API's in offscr16bpp.c. But one missing case from this file in GrOffScreen16BPPPixelDrawMultiple() is, the case for 24bpp (input color parameter). Each case in this API indicates the different BPP that can be passed to this API and the API will convert (from any bpp - 1,4,8,16,24) to 16bpp color before drawing on the frame buffer.

    Regards

    Baskaran

  • Hello TinND,

    I had similar problem, inverted colours on Microtips display connected to C6748 DSP.

    I solved it by inverting colour definitions in grlib.h

    #define ClrBlue                0x00FFFF00    //0x000000FF

    Best Regards

    Jan

  • Hi Jan Rusinsky,

    Inverting color definitions in glib.h only effects if we use these definitions in some draw functions. However, how can we invert C array (result of pnm to c converter) to display a image properly?

    Best regards,

    TinND

  • Hi Baskaran Chidambaram,

    After doing a lot of research in LCD's schematic of  BeagleBone, EVMAM335x and EVMSKAM335x board, I found that they have some differrences in connection order:

    BeagleBone LCD 3.5": LCD_Data[0-4] -->BLUE[3-7]               LCD_Data[5-11] <--> GREEN[2-7]                  LCD_Data[12-16] <---> RED[3-7]

    EVMAM335x LCD:         LCD_Data[0-4] -->BLUE[3-7]               LCD_Data[5-11] <--> GREEN[2-7]                  LCD_Data[12-16] <---> RED[3-7] ....

    EVMSKAM335x LCD:    LCD_Data[0-4] -->RED[3-7]                 LCD_Data[5-11] <--> GREEN[2-7]                  LCD_Data[12-16] <---> BLUE[3-7]  ....

     So I think BeagleBone and EVMAM335x have problems in colors order but EVMSKAM335x does not. Are you sure both of them  (EVMAM335x and EVMSKAM335x) display proper colors?

    As I mentioned previously, BeagleBone displays color properly when I tested raster example! I used bmptorsater tool (from Staterware) to convert my image to C array(24 RGB mode):

    ~ ./a.out 320 240 input.bmp output.h 24 RGB

    Did you use the same command when you used EVMAM335x and EVMSKAM335x (particularly colors order, RGB vs BGR)?

    Best regards,

    TinND

  • Hi All

    I am also trying to run LCD application on BeagleBone (Rev6)  to  display small image using sample  image header file , for that i have installed Sitara SDK on my WIN7 host PC . 

    But I dont know how to start and which libraries needs to compile for rasterdisplay.c , I am using CCS v5.3.

    Can anyone please help to develope this LCD application on BeagleBone

    Thanks

    Ram

  • Hello TinND

    After a vigorous search i find this is a better place to discuss my thoughts and get clarified.

    For my upcoming SYSbios work, i need to have display up on BeagleBone-DVI-D Cape and for this i am using raster.c as a static library. And to verify it as You & Baskaran discussing above ---> rasterdisplay.c & image.h from SYSbios_Industial_SDK are the perfect code to start.

    Thanks to TinND & Baskaran for their contribution.

    But my confusion is whether it is possible raster.c work for BeagleBone-DVI-D Cape  ?

    And what sort of generic changes do i need in rasterdisplay.c or in raster.c to make BeagleBone-DVI-D Cape functional.

    Any help will be greatly appreciated !!

    Thanks