Bugfix #3797: 24-bit BMP images weren't read properly. Standard apparently
authorKen Hughes <khughes@pacific.edu>
Sun, 29 Jan 2006 15:23:26 +0000 (15:23 +0000)
committerKen Hughes <khughes@pacific.edu>
Sun, 29 Jan 2006 15:23:26 +0000 (15:23 +0000)
assumes each raster line is padded to a multiple of 4 bytes.

source/blender/imbuf/intern/bmp.c

index e86507ff103ddb3ebebf5ed8ea04e8dcdedb07ac..c14819c8bdf110649e8d3419647ceedd9278e4e7 100644 (file)
@@ -152,13 +152,18 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags)
                        }
 
                } else if (depth == 24) {
-                       for (i = x * y; i > 0; i--) {
-                               rect[0] = bmp[2];
-                               rect[1] = bmp[1];
-                               rect[2] = bmp[0];
-                               
-                               rect[3] = 255;
-                               rect += 4; bmp += 3;
+                       for (i = y; i > 0; i--) {
+                               int j;
+                               for (j = x ; j > 0; j--) {
+                                       rect[0] = bmp[2];
+                                       rect[1] = bmp[1];
+                                       rect[2] = bmp[0];
+                                       
+                                       rect[3] = 255;
+                                       rect += 4; bmp += 3;
+                               }
+                               /* for 24-bit images, rows are padded to multiples of 4 */
+                               bmp += x % 4;   
                        }
                } else if (depth == 32) {
                        for (i = x * y; i > 0; i--) {