Quellcode durchsuchen

Merge pull request #38 from yangfasheng/master

RGB888 数据相关处理功能代码更新
yangfasheng vor 7 Jahren
Ursprung
Commit
48a4ebc133
4 geänderte Dateien mit 302 neuen und 144 gelöschten Zeilen
  1. 240 115
      src/blit.c
  2. 2 1
      src/color.c
  3. 2 28
      src/image_jpg.c
  4. 58 0
      src/rtgui_driver.c

+ 240 - 115
src/blit.c

@@ -883,32 +883,33 @@ static void BlitRGBtoRGBSurfaceAlpha128(struct rtgui_blit_info *info)
     }
 }
 
-/* fast RGB888->RGB888 blending with surface alpha */
+/* RGB888 -> RGB888 blending with alpha */
 static void BlitRGBtoRGBSurfaceAlpha(struct rtgui_blit_info *info)
 {
-    unsigned int alpha = info->a;
+    unsigned int alpha = info->a >> 3;
 
     if (alpha)
     {
         int width = info->dst_w;
         int height = info->dst_h;
         rt_uint8_t *srcp = (rt_uint8_t *)info->src;
-        int srcskip = info->src_skip;
         rt_uint8_t *dstp = (rt_uint8_t *)info->dst;
-        int dstskip = info->dst_skip;
         int inverse_alpha = 257 - alpha;
 
         while (height--)
         {
             DUFFS_LOOP4(
             {
-                if (alpha == 255)
+                if (alpha == 0xFF >> 3)
                 {
                     *dstp++ = *(srcp++);
                     *dstp++ = *(srcp++);
                     *dstp++ = *(srcp++);
-                    *dstp++ = 255;
-                    srcp++;
+                    if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    {
+                        dstp++;
+                        srcp++;
+                    }
                 }
                 else if (alpha)
                 {
@@ -921,65 +922,89 @@ static void BlitRGBtoRGBSurfaceAlpha(struct rtgui_blit_info *info)
                     *dstp = ((*(srcp)* alpha) + (inverse_alpha * (*dstp))) >> 8;
                     dstp++;
                     srcp++;
-                    *dstp = 255;
-                    dstp++;
-                    srcp++;
+                    if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    {
+                        dstp++;
+                        srcp++;
+                    }
                 }
             }, width);
-            srcp += srcskip;
-            dstp += dstskip;
+            srcp += info->src_skip;
+            dstp += info->dst_skip;
         }
     }
 }
 
-/* fast RGB888->(A)RGB888 blending with surface alpha */
+/* RGB888 -> ARGB8888 blending with alpha */
 static void BlitRGBtoARGBSurfaceAlpha(struct rtgui_blit_info *info)
 {
-    unsigned int alpha = info->a;
-    if(alpha == 128)
-    {
-        BlitRGBtoRGBSurfaceAlpha128(info);
-    }
-    else if (alpha)
+    unsigned int alpha = info->a >> 3;
+
+    if (alpha)
     {
         int width = info->dst_w;
         int height = info->dst_h;
         rt_uint8_t *srcp = (rt_uint8_t *)info->src;
-        int srcskip = info->src_skip;
         rt_uint8_t *dstp = (rt_uint8_t *)info->dst;
-        int dstskip = info->dst_skip;
         int inverse_alpha = 257 - alpha;
 
         while(height--)
         {
             DUFFS_LOOP4(
             {
-                if (alpha == 255)
+                if (alpha == 0xFF >> 3)
                 {
-                    *dstp++ = *(srcp++);
-                    *dstp++ = *(srcp++);
-                    *dstp++ = *(srcp++);
-                    *dstp++ = alpha;
-                    srcp ++;
+                    if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    {
+                        *dstp++ = *(srcp++);
+                        *dstp++ = *(srcp++);
+                        *dstp++ = *(srcp++);
+                        *dstp++ = 0xFF;
+                        srcp++;
+                    }
+                    else
+                    {
+                        *dstp++ = *(srcp + 2);
+                        *dstp++ = *(srcp + 1);
+                        *dstp++ = *(srcp);
+                        *dstp++ = 0xFF;
+                        srcp += 3;
+                    }
                 }
                 else if (alpha)
                 {
-                    *dstp = ((*(srcp) * alpha) + (inverse_alpha * (*dstp))) >> 8;
-                    dstp++;
-                    srcp++;
-                    *dstp = ((*(srcp) * alpha) + (inverse_alpha * (*dstp))) >> 8;
-                    dstp++;
-                    srcp++;
-                    *dstp = ((*(srcp) * alpha) + (inverse_alpha * (*dstp))) >> 8;
-                    dstp++;
-                    srcp++;
-                    *dstp = alpha + ((255 - alpha) * (*dstp)) / 255;
-                    dstp++;
-                    srcp++;
+                    if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    {
+                        *dstp = ((*(srcp)* alpha) + (inverse_alpha * (*dstp))) >> 8;
+                        dstp++;
+                        srcp++;
+                        *dstp = ((*(srcp)* alpha) + (inverse_alpha * (*dstp))) >> 8;
+                        dstp++;
+                        srcp++;
+                        *dstp = ((*(srcp)* alpha) + (inverse_alpha * (*dstp))) >> 8;
+                        dstp++;
+                        srcp++;
+                        *dstp = alpha + ((255 - alpha) * (*dstp)) / 255;
+                        dstp++;
+                        srcp++;
+                    }
+                    else
+                    {
+
+                        *dstp = ((*(srcp + 2) * alpha) + (inverse_alpha * (*dstp))) >> 8;
+                        dstp++;
+                        *dstp = ((*(srcp + 1) * alpha) + (inverse_alpha * (*dstp))) >> 8;
+                        dstp++;
+                        *dstp = ((*(srcp)* alpha) + (inverse_alpha * (*dstp))) >> 8;
+                        dstp++;
+                        *dstp = alpha + ((255 - alpha) * (*dstp)) / 255;
+                        dstp++;
+                        srcp += 3;
+                    }
                 }
             }, width);
-            srcp += srcskip;
-            dstp += dstskip;
+            srcp += info->src_skip;
+            dstp += info->dst_skip;
         }
     }
 }
@@ -1064,18 +1089,30 @@ static void BlitRGBto565PixelAlpha(struct rtgui_blit_info * info)
 {
     int width = info->dst_w;
     int height = info->dst_h;
-    rt_uint32_t *srcp = (rt_uint32_t *)info->src;
-    int srcskip = info->src_skip >> 2;
+    rt_uint8_t *srcp = (rt_uint8_t *)info->src;
+    int srcskip = info->src_skip;
     rt_uint16_t *dstp = (rt_uint16_t *)info->dst;
     int dstskip = info->dst_skip >> 1;
 
     while (height--)
     {
         /* *INDENT-OFF* */
-        DUFFS_LOOP4(
+        width = info->dst_w;
+        while (width--)
         {
-            rt_uint32_t s = *srcp;
-            unsigned alpha = 255;
+            rt_uint8_t alpha = 255;
+            rt_uint32_t s;
+            if (PKG_USING_RGB888_PIXEL_BITS == 32)
+            {
+                s = 0xFF000000 + *srcp + (*(srcp + 1) << 8) + (*(srcp + 2) << 16);
+                srcp += 4;
+            }
+            else
+            {
+                s = 0xFF000000 + (*srcp << 16) + (*(srcp + 1) << 8) + *(srcp + 2);
+                srcp += 3;
+            }
+
             if (info->a > 0 && info->a != 255)
                 alpha = alpha * info->a / 255;
             alpha = alpha >> 3;	/* downscale alpha to 5 bits */
@@ -1089,7 +1126,7 @@ static void BlitRGBto565PixelAlpha(struct rtgui_blit_info * info)
                 {
                     *dstp = (rt_uint16_t)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f));
                 }
-                else if (alpha > 0)
+                else
                 {
                     rt_uint32_t d = *dstp;
                     /*
@@ -1104,9 +1141,8 @@ static void BlitRGBto565PixelAlpha(struct rtgui_blit_info * info)
                     *dstp = (rt_uint16_t)(d | d >> 16);
                 }
             }
-            srcp++;
             dstp++;
-        }, width);
+        }
         /* *INDENT-ON* */
         srcp += srcskip;
         dstp += dstskip;
@@ -1167,114 +1203,141 @@ static void BlitARGBto565PixelAlpha(struct rtgui_blit_info * info)
     }
 }
 
-/* fast ARGB888->(A)RGB888 blending with pixel alpha */
+/* ARGB888 -> RGB888 blending with alpha */
 static void BlitARGBtoRGBPixelAlpha(struct rtgui_blit_info *info)
 {
-    int width = info->dst_w;
+    rt_uint32_t srcpixel;
+    rt_uint32_t srcR, srcG, srcB, srcA;
+    rt_uint8_t dstR, dstG, dstB;
     int height = info->dst_h;
-    rt_uint32_t *srcp = (rt_uint32_t *)info->src;
-    int srcskip = info->src_skip >> 2;
-    rt_uint32_t *dstp = (rt_uint32_t *)info->dst;
-    int dstskip = info->dst_skip >> 2;
 
-    while(height--)
+    while (height--)
     {
-        DUFFS_LOOP4(
-        {
-            rt_uint32_t dalpha;
-            rt_uint32_t d;
-            rt_uint32_t s1;
-            rt_uint32_t d1;
-            rt_uint32_t s = *srcp;
-            rt_uint32_t alpha = s >> 24;
+        rt_uint32_t *src = (rt_uint32_t *)info->src;
+        rt_uint8_t *dst = info->dst;
+        int width = info->dst_w;
 
+        while (width--)
+        {
+            srcpixel = *src++;
+            srcA = (rt_uint8_t)(srcpixel >> 24);
             if (info->a > 0 && info->a != 255)
-                alpha = alpha * info->a / 255;
-            /* FIXME: Here we special-case opaque alpha since the
-               compositioning used (>>8 instead of /255) doesn't handle
-               it correctly. Also special-case alpha=0 for speed?
-               Benchmark this! */
-            if(alpha == 255 || info->a == 0)
+                srcA = srcA * info->a / 255;
+
+            /* not do alpha blend */
+            if (srcA >> 3 == 0xFF >> 3)
             {
-                *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000);
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                {
+                    *dst++ = (rt_uint8_t)(srcpixel);
+                    *dst++ = (rt_uint8_t)(srcpixel >> 8);
+                    *dst++ = (rt_uint8_t)(srcpixel >> 16);
+                    dst++;
+                }
+                else
+                {
+                    *dst++ = (rt_uint8_t)(srcpixel >> 16);
+                    *dst++ = (rt_uint8_t)(srcpixel >> 8);
+                    *dst++ = (rt_uint8_t)(srcpixel);
+                }
+            }
+            else if (srcA >> 3 == 0)
+            {
+                /* keep original pixel data */
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    dst += 4;
+                else
+                    dst += 3;
             }
             else
             {
-                /*
-                 * take out the middle component (green), and process
-                 * the other two in parallel. One multiply less.
-                 */
-                d = *dstp;
-                dalpha = d & 0xff000000;
-                s1 = s & 0xff00ff;
-                d1 = d & 0xff00ff;
-                d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
-                s &= 0xff00;
-                d &= 0xff00;
-                d = (d + ((s - d) * alpha >> 8)) & 0xff00;
-                *dstp = d1 | d | dalpha;
+                int alpha = srcA + 1;
+                int inverse_alpha = 257 - alpha;
+
+                srcR = (rt_uint8_t)srcpixel;
+                srcG = (rt_uint8_t)(srcpixel >> 8);
+                srcB = (rt_uint8_t)(srcpixel >> 16);
+
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                {
+                    dstR = *dst;
+                    dstG = *(dst + 1);
+                    dstB = *(dst + 2);
+                }
+                else
+                {
+                    dstR = *(dst + 2);
+                    dstG = *(dst + 1);
+                    dstB = *(dst);
+                }
+
+                *dst++ = ((srcR * alpha) + (inverse_alpha * dstR)) >> 8;
+                *dst++ = ((srcG * alpha) + (inverse_alpha * dstG)) >> 8;
+                *dst++ = ((srcB * alpha) + (inverse_alpha * dstB)) >> 8;
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    dst++;
             }
-            ++srcp;
-            ++dstp;
-        }, width);
-        srcp += srcskip;
-        dstp += dstskip;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
     }
 }
 
 static void BlitAlphatoRGB888PixelAlpha(struct rtgui_blit_info *info)
 {
-    rt_uint32_t srcpixel;
     rt_uint32_t srcR, srcG, srcB, srcA;
-    rt_uint32_t dstpixel;
-    rt_uint32_t dstR, dstG, dstB;
+    rt_uint8_t dstR, dstG, dstB;
+    int height = info->dst_h;
 
     srcR = info->r;
     srcG = info->g;
     srcB = info->b;
 
-    while (info->dst_h--)
+    while (height--)
     {
-        rt_uint8_t *src = (rt_uint8_t *)info->src;
-        rt_uint32_t *dst = (rt_uint32_t *)info->dst;
-        int n = info->dst_w;
-        while (n--)
+        rt_uint8_t *src = info->src;
+        rt_uint8_t *dst = info->dst;
+        int width = info->dst_w;
+
+        while (width--)
         {
-            srcA = (rt_uint8_t)(*src);
+            srcA = *src++;
             if (info->a > 0 && info->a != 255)
                 srcA = srcA * info->a / 255;
-            ARGB8888_FROM_RGBA(srcpixel, srcR, srcG, srcB, srcA);
 
             /* not do alpha blend */
-            if (srcA == 255)
+            if (srcA >> 3 == 0xFF >> 3)
             {
-                *dst = srcpixel;
+                *dst++ = srcR;
+                *dst++ = srcG;
+                *dst++ = srcB;
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    dst++;
             }
             else if (srcA >> 3 == 0)
             {
                 /* keep original pixel data */
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    dst += 4;
+                else
+                    dst += 3;
             }
             else
             {
                 int alpha = srcA + 1;
                 int inverse_alpha = 257 - alpha;
 
-                dstpixel = *dst;
-                dstR = (rt_uint8_t)(dstpixel >> 16);
-                dstG = (rt_uint8_t)(dstpixel >> 8);
-                dstB = (rt_uint8_t)dstpixel;
+                dstR = *dst;
+                dstG = *(dst + 1);
+                dstB = *(dst + 2);
 
-                dstR = ((srcR * alpha) + (inverse_alpha * dstR)) >> 8;
-                dstG = ((srcG * alpha) + (inverse_alpha * dstG)) >> 8;
-                dstB = ((srcB * alpha) + (inverse_alpha * dstB)) >> 8;
-
-                *dst = ((rt_uint32_t)0xFF << 24) | ((rt_uint32_t)dstR << 16) | ((rt_uint32_t)dstG << 8) | dstB;
+                *dst++ = ((srcR * alpha) + (inverse_alpha * dstR)) >> 8;
+                *dst++ = ((srcG * alpha) + (inverse_alpha * dstG)) >> 8;
+                *dst++ = ((srcB * alpha) + (inverse_alpha * dstB)) >> 8;
+                if (PKG_USING_RGB888_PIXEL_BITS == 32)
+                    dst++;
             }
-
-            ++src;
-            ++dst;
         }
-
         info->src += info->src_pitch;
         info->dst += info->dst_pitch;
     }
@@ -1457,6 +1520,68 @@ BlitRGB565toARGB8888(struct rtgui_blit_info * info)
     BlitRGB565to32(info, RGB565_ARGB8888_LUT);
 }
 
+static void
+BlitRGB565toRGB888(struct rtgui_blit_info * info)
+{
+    if (PKG_USING_RGB888_PIXEL_BITS == 32)
+    {
+        BlitRGB565to32(info, RGB565_ARGB8888_LUT);
+    }
+    else
+    {
+        rt_uint32_t srcR, srcG, srcB, srcA;
+        rt_uint8_t dstR, dstG, dstB;
+        int height = info->dst_h;
+        rt_uint16_t *src = (rt_uint16_t *)info->src;
+        rt_uint8_t *dst = info->dst;
+
+        while (height--)
+        {
+            int width = info->dst_w;
+
+            while (width--)
+            {
+                srcA = 255;
+                if (info->a > 0 && info->a != 255)
+                    srcA = srcA * info->a / 255;
+
+                /* not do alpha blend */
+                if (srcA >> 3 == 0xFF >> 3)
+                {
+                    *dst++ = (rt_uint8_t)((*src >> 8) & 0xF8);
+                    *dst++ = (rt_uint8_t)((*src >> 3) & 0xFC);
+                    *dst++ = (rt_uint8_t)((*src & 0x1F) << 3);
+                }
+                else if (srcA >> 3 == 0)
+                {
+                    /* keep original pixel data */
+                    dst += 3;
+                }
+                else
+                {
+                    int alpha = srcA + 1;
+                    int inverse_alpha = 257 - alpha;
+
+                    srcR = (rt_uint8_t)((*src >> 8) & 0xF8);
+                    srcG = (rt_uint8_t)((*src >> 3) & 0xFC);
+                    srcB = (rt_uint8_t)((*src & 0x1F) << 3);
+
+                    dstR = *(dst + 2);
+                    dstG = *(dst + 1);
+                    dstB = *(dst);
+
+                    *dst++ = ((srcR * alpha) + (inverse_alpha * dstR)) >> 8;
+                    *dst++ = ((srcG * alpha) + (inverse_alpha * dstG)) >> 8;
+                    *dst++ = ((srcB * alpha) + (inverse_alpha * dstB)) >> 8;
+                }
+                src++;
+            }
+            src += info->src_skip;
+            dst += info->dst_skip;
+        }
+    }
+}
+
 void rtgui_blit(struct rtgui_blit_info * info)
 {
     if (info->src_h == 0 ||
@@ -1490,7 +1615,7 @@ void rtgui_blit(struct rtgui_blit_info * info)
             Blit565to565PixelAlpha(info);
             break;
         case RTGRAPHIC_PIXEL_FORMAT_RGB888:
-            BlitRGB565toARGB8888(info);
+            BlitRGB565toRGB888(info);
             break;
         case RTGRAPHIC_PIXEL_FORMAT_ARGB888:
             BlitRGB565toARGB8888(info);

+ 2 - 1
src/color.c

@@ -22,6 +22,7 @@
  * 2009-10-16     Bernard      first version
  */
 #include <rtgui/color.h>
+#include <rtconfig.h>
 
 const rtgui_color_t red     = RTGUI_RGB(0xff, 0x00, 0x00);
 const rtgui_color_t green   = RTGUI_RGB(0x00, 0xff, 0x00);
@@ -43,7 +44,7 @@ const static rt_uint8_t pixel_bits_table[] =
     16, /* RGB565 */
     16, /* BGR565 */
     18, /* RGB666 */
-    32, /* RGB888 */
+    PKG_USING_RGB888_PIXEL_BITS, /* RGB888 */
     32, /* ARGB888 */
 };
 

+ 2 - 28
src/image_jpg.c

@@ -811,7 +811,7 @@ static rt_bool_t rtgui_image_jpeg_load(struct rtgui_image *image, struct rtgui_f
         {
             rt_uint8_t *pixels = RT_NULL;
             
-            if (jpeg->tjpgd.format == 0)
+            if (jpeg->tjpgd.format == 0 && PKG_USING_RGB888_PIXEL_BITS == 32)
                 pixels = (rt_uint8_t *)rtgui_malloc(4 * image->w * image->h);
 
             jpeg->pixels = (rt_uint8_t *)rtgui_malloc(jpeg->byte_per_pixel * image->w * image->h);
@@ -926,33 +926,7 @@ static void rtgui_image_jpeg_blit(struct rtgui_image *image,
     w = _UI_MIN(image->w - xoff, rtgui_rect_width (*dst_rect));
     h = _UI_MIN(image->h - yoff, rtgui_rect_height(*dst_rect));
 
-    if (rtgui_dc_get_pixel_format(dc) == RTGRAPHIC_PIXEL_FORMAT_RGB888 &&
-            jpeg->tjpgd.format != 0)
-    {
-        jpeg->tjpgd.format = 0;
-        jpeg->byte_per_pixel = 3;
-    }
-    else if (rtgui_dc_get_pixel_format(dc) == RTGRAPHIC_PIXEL_FORMAT_RGB565 &&
-             jpeg->tjpgd.format != 1)
-    {
-        jpeg->tjpgd.format = 1;
-        jpeg->byte_per_pixel = 2;
-    }
-
-    if (!jpeg->is_loaded)
-    {
-        JRESULT ret;
-
-        /* TODO support xoff/yoff. */
-        jpeg->dst_x = dst_rect->x1;
-        jpeg->dst_y = dst_rect->y1;
-        jpeg->dst_w = w;
-        jpeg->dst_h = h;
-        ret = jd_decomp(&jpeg->tjpgd, tjpgd_out_func, 0);
-        if (ret != JDR_OK)
-            return;
-    }
-    else
+    if (jpeg->pixels)
     {
         if ((rtgui_dc_get_pixel_format(dc) == RTGRAPHIC_PIXEL_FORMAT_RGB888 && jpeg->tjpgd.format == 0) ||
                 (rtgui_dc_get_pixel_format(dc) == RTGRAPHIC_PIXEL_FORMAT_RGB565 && jpeg->tjpgd.format == 1))

+ 58 - 0
src/rtgui_driver.c

@@ -381,16 +381,38 @@ static void _rgb565p_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
 
 static void _rgb888_set_pixel(rtgui_color_t *c, int x, int y)
 {
+#ifdef PKG_USING_RGB888_PIXEL_BITS_32
     *GET_PIXEL(rtgui_graphic_get_device(), x, y, rtgui_color_t) = *c;
+#else
+    rt_uint8_t *pixel = GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint8_t);
+
+    *pixel = (*c >> 16) & 0xFF;
+    pixel++;
+    *pixel = (*c >> 8) & 0xFF;
+    pixel++;
+    *pixel = (*c) & 0xFF;
+#endif // PKG_USING_RGB888_PIXEL_BITS_32
 }
 
 static void _rgb888_get_pixel(rtgui_color_t *c, int x, int y)
 {
+#ifdef PKG_USING_RGB888_PIXEL_BITS_32
     *c = ((rtgui_color_t)*GET_PIXEL(rtgui_graphic_get_device(), x, y, rtgui_color_t) & 0xFFFFFF) + 0xFF000000;
+#else
+    rt_uint8_t *pixel = GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint8_t);
+
+    *c = 0xFF000000;
+    *c = (*pixel << 16);
+    pixel++;
+    *c = (*pixel << 8);
+    pixel++;
+    *c = (*pixel);
+#endif // PKG_USING_RGB888_PIXEL_BITS_32 
 }
 
 static void _rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
 {
+#ifdef PKG_USING_RGB888_PIXEL_BITS_32
     int index;
     rtgui_color_t *pixel_ptr;
 
@@ -402,10 +424,28 @@ static void _rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
         *pixel_ptr = *c;
         pixel_ptr++;
     }
+#else
+    int index;
+    rt_uint8_t *pixel_ptr;
+
+    /* get pixel pointer in framebuffer */
+    pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t);
+
+    for (index = x1; index < x2; index++)
+    {
+        *pixel_ptr = (*c >> 16) & 0xFF;
+        pixel_ptr++;
+        *pixel_ptr = (*c >> 8) & 0xFF;
+        pixel_ptr++;
+        *pixel_ptr = (*c) & 0xFF;
+        pixel_ptr++;
+    }
+#endif // PKG_USING_RGB888_PIXEL_BITS_32 
 }
 
 static void _rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
 {
+#ifdef PKG_USING_RGB888_PIXEL_BITS_32
     struct rtgui_graphic_driver *drv;
     rtgui_color_t *dst;
     int index;
@@ -417,6 +457,24 @@ static void _rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
         *dst = *c;
         dst += drv->width;
     }
+#else
+    struct rtgui_graphic_driver *drv;
+    rt_uint8_t *dst;
+    int index;
+
+    drv = rtgui_graphic_get_device();
+    dst = GET_PIXEL(drv, x, y1, rt_uint8_t);
+    for (index = y1; index < y2; index++)
+    {
+        *dst = (*c >> 16) & 0xFF;
+        dst++;
+        *dst = (*c >> 8) & 0xFF;
+        dst++;
+        *dst = (*c) & 0xFF;
+        dst++;
+        dst += drv->width;
+    }
+#endif // PKG_USING_RGB888_PIXEL_BITS_32 
 }
 
 static void _argb888_set_pixel(rtgui_color_t *c, int x, int y)