GlDrawPixels in grayscale?

I have an image that I get as follows:

glDrawPixels(image->width, image->height, GL_BGR, GL_UNSIGNED_BYTE, image->imageData);

Anyway, can I draw it in shades of gray (without loading it first into the texture)? I don't care if, say, the blue component is used for the gray value and not for the L2 norm or something else, I just need a quick and dirty output.

GL_LUMINANCE will be great, except that it will not work on a three-channel image.


@timday:

http://img164.imageshack.us/img164/3603/grayscale.png

+3
source share
1 answer

A perverted idea for you to try, and I have no idea if this will work:

glPixelZoom(1.0f/3.0f,1.0f);
glDrawPixels(3*width,height,GL_LUMINANCE,GL_UNSIGNED_BYTE,data);

.. 3- () 3 , x. , GL glDrawPixels, , .

+5

Source: https://habr.com/ru/post/1706364/


All Articles