Browse Source

TGA loader fix to new optimized path by Jerry Jansson

Sean Barrett 11 năm trước cách đây
mục cha
commit
d0c33a77f9
1 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 4 4
      stb_image.h

+ 4 - 4
stb_image.h

@@ -3272,7 +3272,7 @@ static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int
    *y = tga_height;
    if (comp) *comp = tga_comp;
 
-   tga_data = (unsigned char*)malloc( tga_width * tga_height * req_comp );
+   tga_data = (unsigned char*)malloc( tga_width * tga_height * tga_comp );
    if (!tga_data) return stbi__errpuc("outofmem", "Out of memory");
 
    // skip to the data's starting position (offset usually = 0)
@@ -3365,9 +3365,9 @@ static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int
       {
          for (j = 0; j*2 < tga_height; ++j)
          {
-            int index1 = j * tga_width * req_comp;
-            int index2 = (tga_height - 1 - j) * tga_width * req_comp;
-            for (i = tga_width * req_comp; i > 0; --i)
+            int index1 = j * tga_width * tga_comp;
+            int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
+            for (i = tga_width * tga_comp; i > 0; --i)
             {
                unsigned char temp = tga_data[index1];
                tga_data[index1] = tga_data[index2];