Hello,   I am relatively new to FreeType, and first I want to say thank you
to the developers.  Well, my question is about the format of the bitmap
buffer returned by using FT_RENDER_MODE_MONO.  I want to get bitmaps that
are not anti-aliased and my end target is OpenGL textures that use 32-bits
per pixel (8 per channel RGBA).  So I need to do the conversion from the
1-bit per pixel output.  What I would like is for all four components of the
texture (unsigned bytes) to be either 0 or 255 based on the glyph bitmap.
 Below is some code that I tried but it only rendered garbage.  Any
suggestions on how to go about this?

//Allocate memory for the texture data (four component)
GLubyte *data = new GLubyte[4 * slot->bitmap.width * slot->bitmap.rows];

//Set color to white and alpha to bitmap value
unsigned int bmIndex = 0, dataIndex = 0, byteIndex, bitOffset;
unsigned char byte;
for(int j=0; j < slot->bitmap.rows; j++) {
for(int i=0; i < slot->bitmap.width; i++){

//Get the byte index and bit offset
                        byteIndex = bmIndex / 8;
                        bitOffset = bmIndex % 8;

                        //Get the byte
byte = slot->bitmap.buffer[byteIndex];

                        //Rotate, AND, and multiply to get 0 or 255 value
                        byte = ((byte >> bitOffset) & 1) * 255;

                        //Set all four components of the GL texture
data[dataIndex++] = byte;
data[dataIndex++] = byte;
data[dataIndex++] = byte;
data[dataIndex++] = byte;
                        //Increment bmIndex
                        bmIndex++;
}
}

Thanks,
    Graham
_______________________________________________
Freetype mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to