| /** | /** | ||||
| * Copy user-provide bitmap bits into texture buffer, expanding | * Copy user-provide bitmap bits into texture buffer, expanding | ||||
| * bits into texels. | * bits into texels. | ||||
| * "On" bits will set texels to 0xff. | |||||
| * "On" bits will set texels to 0x0. | |||||
| * "Off" bits will not modify texels. | * "Off" bits will not modify texels. | ||||
| * Note that the image is actually going to be upside down in | * Note that the image is actually going to be upside down in | ||||
| * the texture. We deal with that with texcoords. | * the texture. We deal with that with texcoords. | ||||
| const GLubyte *bitmap, | const GLubyte *bitmap, | ||||
| ubyte *destBuffer, uint destStride) | ubyte *destBuffer, uint destStride) | ||||
| { | { | ||||
| GLint row, col; | |||||
| #define SET_PIXEL(COL, ROW) \ | |||||
| destBuffer[(py + (ROW)) * destStride + px + (COL)] = 0x0; | |||||
| for (row = 0; row < height; row++) { | |||||
| const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, | |||||
| bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); | |||||
| if (unpack->LsbFirst) { | |||||
| /* Lsb first */ | |||||
| GLubyte mask = 1U << (unpack->SkipPixels & 0x7); | |||||
| for (col = 0; col < width; col++) { | |||||
| if (*src & mask) { | |||||
| SET_PIXEL(col, row); | |||||
| } | |||||
| if (mask == 128U) { | |||||
| src++; | |||||
| mask = 1U; | |||||
| } | |||||
| else { | |||||
| mask = mask << 1; | |||||
| } | |||||
| } | |||||
| /* get ready for next row */ | |||||
| if (mask != 1) | |||||
| src++; | |||||
| } | |||||
| else { | |||||
| /* Msb first */ | |||||
| GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); | |||||
| for (col = 0; col < width; col++) { | |||||
| if (*src & mask) { | |||||
| SET_PIXEL(col, row); | |||||
| } | |||||
| if (mask == 1U) { | |||||
| src++; | |||||
| mask = 128U; | |||||
| } | |||||
| else { | |||||
| mask = mask >> 1; | |||||
| } | |||||
| } | |||||
| /* get ready for next row */ | |||||
| if (mask != 128) | |||||
| src++; | |||||
| } | |||||
| } /* row */ | |||||
| destBuffer += py * destStride + px; | |||||
| #undef SET_PIXEL | |||||
| _mesa_expand_bitmap(width, height, unpack, bitmap, | |||||
| destBuffer, destStride, 0x0); | |||||
| } | } | ||||