Use row stride instead of width when getting colour index texels.
authorMichel Dänzer <daenzer@vmware.com>
Wed, 30 Mar 2011 08:48:37 +0000 (10:48 +0200)
committerMichel Dänzer <daenzer@vmware.com>
Wed, 30 Mar 2011 08:48:37 +0000 (10:48 +0200)
Untested, noticed while working on the depth/stencil fix.

src/mesa/main/texgetimage.c

index db2cc840e5e2c13cad19f277099453de158f0396..7070a29fb9d21b9664ce4967201c18ac02bebb69 100644 (file)
@@ -74,6 +74,7 @@ get_tex_color_index(struct gl_context *ctx, GLuint dimensions,
    const GLint width = texImage->Width;
    const GLint height = texImage->Height;
    const GLint depth = texImage->Depth;
+   const GLint rowstride = texImage->RowStride;
    const GLuint indexBits =
       _mesa_get_format_bits(texImage->TexFormat, GL_TEXTURE_INDEX_SIZE_EXT);
    const GLbitfield transferOps = 0x0;
@@ -89,14 +90,14 @@ get_tex_color_index(struct gl_context *ctx, GLuint dimensions,
 
          if (indexBits == 8) {
             const GLubyte *src = (const GLubyte *) texImage->Data;
-            src += width * (img * texImage->Height + row);
+            src += rowstride * (img * height + row);
             for (col = 0; col < width; col++) {
                indexRow[col] = src[col];
             }
          }
          else if (indexBits == 16) {
             const GLushort *src = (const GLushort *) texImage->Data;
-            src += width * (img * texImage->Height + row);
+            src += rowstride * (img * height + row);
             for (col = 0; col < width; col++) {
                indexRow[col] = src[col];
             }