GUI_BMP_DrawEx swaps red and blue

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • GUI_BMP_DrawEx swaps red and blue

      Hello,
      to display bitmaps from SD card I use the drawing function

      Source Code

      1. GUI_BMP_DrawEx(APP_GetData, (void*)&SD_File, 0, 0);
      with the import function


      Source Code

      1. int APP_GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Offs)
      2. {
      3. UINT NumBytesRead;
      4. U8 _acBuffer[2 * XSIZE_PHYS]; /*buffer must hold at least one line (2 byte * 800 pix)*/
      5. f_lseek((FIL *)p, Offs); /*set file pointer to the offset location*/
      6. f_read((FIL *)p, (void *)_acBuffer, NumBytesReq, &NumBytesRead); /*read data into buffer*/
      7. *ppData = (const U8 *)_acBuffer; /*data pointer = beginning of the buffer*/
      8. return (NumBytesRead); /*return number of read bytes*/
      9. }
      My color order is RGB.

      Source Code

      1. #define GUI_USE_ARGB 1 /*order of colors R|G|B*/
      On the screen the bitmaps are shown with red and blue swapped.
      On a PC the colors the same bmp files are displayed correctly.
      It looks like the saved bitmaps are coded RGB but GUI_BMP_DrawEx() expects BGR. How can this problem be solved?

      Regards
      Jan