achimdoebler / UGUI

µGUI - Open Source GUI module for embedded systems
Other
1.2k stars 415 forks source link

Invalid color conversion done in UG_DrawBMP for a BMP 565 format screen #22

Open ajaiantilal opened 7 years ago

ajaiantilal commented 7 years ago

In UG_DrawBMP(), invalid color conversion done when BMP format is 565.

just before this line the color is set to 888 format, but that causes wrong colors to be displayed on a 565 format screen https://github.com/achimdoebler/UGUI/blob/master/ugui.c#L5840

a possible fix:

         tmp = *p++;
         #ifdef USE_COLOR_RGB565
            UG_DrawPixel( xp++ , yp , tmp );
         #else
            /* Convert RGB565 to RGB888 */
            r = (tmp>>11)&0x1F;
            r<<=3;
            g = (tmp>>5)&0x3F;
            g<<=2;
            b = (tmp)&0x1F;
            b<<=3;
            c = ((UG_COLOR)r<<16) | ((UG_COLOR)g<<8) | (UG_COLOR)b;
            UG_DrawPixel( xp++ , yp , c );
         #endif
andreygursky commented 6 years ago

@achimdoebler:

BTW: No, the project is still alive! [06.08.2017]

Good news, thanks! So please commit this fix or explain in short why it doesn't fit.

roman200918715 commented 6 years ago

I had tested this fix, and the results are success