Colors wrong after update from emWin 6.30 to emWin 6.32

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

    • Colors wrong after update from emWin 6.30 to emWin 6.32

      Dear Sirs,

      In order to have a newer version we updated from emWin 6.30 to emWin 6.32
      Thereafter the colors on our TFT where wrong.

      The blue changed to kind of brown.
      (see attached photos)

      WE DID NOT CHANGE A SINGLE LINE OF CODE!

      Just the replacement of emWin 6.30 to emWin 6.32 caused the fault.

      Here is the the Display driver we use:
      GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66720, GUIDRV_FLEXCOLOR_M16C1B16);

      If we turn off the cache it does not help.

      What can we do to use newer emWin Versions in future?

      Thanks a lot
      Andreas
      Images
      • ColorOK.jpg

        86.84 kB, 480×640, viewed 417 times
      • ColorWrong.jpg

        87.95 kB, 480×640, viewed 429 times
    • Hello,
      meanwhile I found a possible reason:

      The new KEIL Library we are using was compiled with GUI_USE_ARGB = 1.

      The previous library was built with GUI_USE_ARGB = 0.


      I just don´t know why this was changed...


      best regards

      Andreas
    • Hello,
      again a step further:

      we changed in LcdConf.c:
      #define COLOR_CONVERSION GUICC_M565
      to:
      #define COLOR_CONVERSION GUICC_565

      Colors in the main application are correct now.


      But unfortunateley we also use GUI_BMP_Serialize() for doing a screen shot.

      The bitmap created by this still shows the colors wrong.

      Somehow the GUI_BMP_Serialize() doesn´t take any notice from the setting of COLOR_CONVERSION in LcdConf.c?


      We would be happy for a workaround, so we can use the newer library


      best regards

      Andreas
    • Hi Andreas,

      Yes, the swapped colors look like the color format was switched from ABGR to ARGB. The folks from KEIL can probably tell you why they switched it, but I suppose they did because we recommend to use ARGB which is now the standard.

      Andy_AN2 wrote:

      we changed in LcdConf.c:
      #define COLOR_CONVERSION GUICC_M565
      to:
      #define COLOR_CONVERSION GUICC_565

      That change should not be necessary. GUICC_M565 is already the color configuration for GUI_USE_ARGB==1.

      Andy_AN2 wrote:

      Colors in the main application are correct now.

      I assume this is because you are still using colors in your application that are in the old ABGR format. You need to define custom colors with the GUI_MAKE_COLOR() macro, which automatically converts the color into the correct format. For example:

      C Source Code

      1. //
      2. // Custom color
      3. // Expands to 0xFFAA33FF when GUI_USE_ARGB==1.
      4. //
      5. #define COLOR_0 GUI_MAKE_COLOR(0x00FF33AA)

      GUI_BMP_Serialize() also uses the color conversion you set for the driver. So when you set it back to GUICC_M565, the colors should be correct.

      Please let me know if this fixes your issues.

      Best regards,
      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Hello Florian,

      unfortunately another problem occured due to GUI_USE_ARGB==1.

      With color constants GUI_MAKE_COLOR() macro swapps the colors accordingly, so all is fine.

      But we also have small icons for Buttons stored in *.dta files.
      They are loaded with BUTTON_SetStreamedBitmap() function. As there is no similar conversion like GUI_MAKE_COLOR macro the colors are wrong in the button.
      I tried to create first the bitmap with GUI_CreateBitmapFromStream() and thereafter apply it to the button with BUTTON_SetBitmap() but colors are still wrong.

      How can the bitmaps be converted so they work with GUI_USE_ARGB==1?


      Thanks a lot again for your help

      Andreas
    • Hi Andreas,

      The bitmaps were probably converted when the ABGR format was used. So the colors in the bitmap are still in the ABGR format.

      You have to re-convert the bitmaps to .DTA with the Bitmap Converter again, but with "Save colors in ARGB mode" set in the program options.

      Best regards,
      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Hello Florian,

      Thank you very much for this hint!
      I did a test and it worked very well.

      However there is one point left:
      For compatibility reasons we want to be able to link to older versions of emWin without change of our source code.
      The GUI_MAKE_COLOR() automatically checks GUI_USE_ARGB Flag an sets the colors correct. So we can change the library no problem.
      But in terms of dta files there is no automatic, this is done external.
      So in order to have the software working with either library I have to provide two sets of Icons: One for GUI_USE_ARGB=0 and GUI_USE_ARGB=1
      and select them depending on GUI_USE_ARGB.
      I think the function that loads the bitmap from stream should take care of GUI_USE_ARGB while loading and swap colors?


      Another solution would be a function that enables us to swap red and blue in an emwin bitmap once it is created from stream...


      Thank you very much for your comment


      Andreas
    • Hi Andreas,

      I'm afraid this is not so easily done.

      Unfortunately, the streamed bitmap header does not contain the USE_ARGB flag. Also, the bitmap created by GUI_CreateBitmapFromStream() references a specific bitmap function table based on the format read from the streamed bitmap header. E.g., if the format M8888I was read from the file, then the function table GUI_DRAW_BMPM8888I is set to the GUI_BITMAP.

      These bitmap functions use the ARGB/ABGR format determined by the preprocessor option GUI_USE_ARGB. In other words, it's either ARGB or ABGR which can only be changed at compile time.

      If you want to keep this generic, you would have to save the ARGB flag coupled with a streamed bitmap. Then, the bitmap data would have to be swapped during runtime, if the GUI_USE_ARGB define is not the same as the ARGB flag the streamed bitmap has.

      But I doubt that this much work would be worth it, especially since ARGB has been the default since V5.48 (more than 5 years old).

      I would recommend to convert the streamed bitmaps to ARGB once, then you would still be able to run your code base with older emWin versions (up to 5.48).

      I hope this helps, if anything is still unclear, just let me know.

      Best regards,
      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.