I want to display the color white as red

Hello there,

i have the following problem. I used the QT-Toolkit from which i use the QImage object as buffer object for new image bits.

It is a 8bit grayscale image, which means that the color range
reaches from 0 to 255. The color black is 0 and 255 is white.

In the draw function i use the glTextlTexImage2D() function to draw the image bits into the texture. Before anyone ask… it works, very well with a high CPU performance.

Here is the code snippet:

glTexImage2D( 
      GL_TEXTURE_2D, 
      0, 
      GL_RGB8, 
      m_image.width(), 
      m_image.height(), 
      0, GL_LUMINANCE, 
      GL_UNSIGNED_BYTE, 
      m_image.bits());   

Now i change the color table from the image object, that the
color 255 is only used for the red part of the RGB definition.

example:
RGB(255, 0, 0)

Now i have guessed that the color white change to red if i draw the image to the texture but it isn’t so.

Is it possible that i have to change also the color table from the 2D texture or could anyone give me a hint to solve this problem.

regards

Treehouse

If you only want to use a red-shaded texture try using GL_RED instead of GL_LUMINANCE. If you want more colors, you need GL_COLOR_INDEX, but don’t ask me, how to transfer the color palette.

But if you ask me, I wouldn’t use indexed images at all. If memory isn’t an issue, use truecolor images (16.7 mil. colors) with GL_RGB or GL_BGR_EXT.

hth,
Shinta

If you define your texture like this, you can just use blending and glColor4f/3f to specify what colour you want it displayed in.

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, mbWidth, mbHeight,
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, m_monoBitmap );

and here’s my blending definition:
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.