Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jun 2014 13:27:57 GMT
From:      seiya@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r269557 - soc2014/seiya/bootsplash/sys/dev/fb
Message-ID:  <201406141327.s5EDRvhk020986@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: seiya
Date: Sat Jun 14 13:27:57 2014
New Revision: 269557
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269557

Log:
  support BMP files compressed by RLE8

Modified:
  soc2014/seiya/bootsplash/sys/dev/fb/bmp.c

Modified: soc2014/seiya/bootsplash/sys/dev/fb/bmp.c
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bmp.c	Sat Jun 14 12:56:07 2014	(r269556)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bmp.c	Sat Jun 14 13:27:57 2014	(r269557)
@@ -138,7 +138,7 @@
 bmp_draw(video_adapter_t *adp, BMP_INFO *bmp_info, int sx, int sy, int iy,
          int width, int height)
 {
-    int		i;
+    int		i, next_line;
     static int  cleared;
 
     if (bmp_info->data == NULL) {	/* init failed, do nothing */
@@ -184,12 +184,34 @@
             bmp_info->index += bmp_info->width * (bmp_info->height - iy - height);
             break;
 
-        case BI_RLE4: case BI_RLE8:
-            for (i = bmp_info->height; i > iy + height;  i--){
-                while (*bmp_info->index != 0 && *(bmp_info->index+1))
-                    bmp_info->index++;
+        case BI_RLE4:
+	    return(1); /* TODO */
+
+	case BI_RLE8:
+            for (i = bmp_info->height; i > iy + height;  i--) {
+
+                for(next_line = 0; next_line == 0;){
+                if (*bmp_info->index) {
+                    bmp_info->index += 2;
+                } else {
+                    switch(*(bmp_info->index+1)) {
+                        case 0: /* end of line */
+                            bmp_info->index += 2;
+                            next_line = 1;
+                            break;
+                        case 1: /* end of bitmap */
+                            bmp_info->index = NULL;
+                            return(1);
+                        case 2: /* move */
+                            bmp_info->index += 4;
+                            break;
+                        default: /* literal bitmap data */
+                            bmp_info->index += 2 + *(bmp_info->index + 1) + (*(bmp_info->index + 1) & 1);
+                            break;
+                    }
+                }
+                }
             }
-            bmp_info->index += 2;
             break;
     }
 
@@ -371,12 +393,10 @@
 bmp_DecodeRLE8(BMP_INFO *info, int line, int sx, int width)
 {
     int         i;
-    int		count;		/* number of drawn pixels */
-    int		x,y;		/* screen position */
+    int		x,y;		/* screen position on screen */
 
-    count = 0;
-    x = sx;			/* starting position */
     y = line;
+    x = sx;
 
     /* loop reading data */
     for(;;) {
@@ -385,17 +405,9 @@
 	 * two colour indexes to alternate between for the run
 	 */
 	if (*info->index) {
-	    for (i = 0; i < *info->index && count < width; i++, count++, x++)
+	    for (i = 0; i < *info->index && (x - sx) < width; i++, x++)
 		bmp_SetPix(info, x, y, *(info->index+1));
 
-	    /* go to the next line */
-	    if(count == width){
-		for (; *info->index != 0 && *(info->index+1) != 0; info->index++)
-			;
-                info->index += 2;
-		return;
-	    }
-
 	    info->index += 2;
         /*
 	 * A leading zero is an escape; it may signal the end of the
@@ -415,20 +427,10 @@
 		info->index += 4;
 		break;
 	    default:				/* literal bitmap data */
-		for (i = 0; i < *(info->index + 1) && count < width; i++, count++, x++)
+		for (i = 0; i < *(info->index + 1) && (x - sx) < width; i++, x++)
 		    bmp_SetPix(info, x, y, *(info->index + 2 + i));
 
-		/* go to the next line */
-		if(count == width){
-		for (; *info->index != 0 && *(info->index+1) != 0; info->index++)
-			;
-		    info->index += 2;
-		    return;
-		}
-
-		/* must be an even count */
-		info->index += 2 + i + (i & 1);
-
+                info->index += 2 + i + (i & 1);
 		break;
 	    }
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406141327.s5EDRvhk020986>