tags:

views:

291

answers:

1
+2  A: 

A perverse idea for you to try, and I've no idea if it'll work:

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

ie treat your 3-channel image as being a 1-channel (grayscale) image 3 times as wide, and compensate for this by squishing the width using the x zoom factor. I believe GL always does nearest-neighbour sampling for zoomed glDrawPixels, so it ought to consistently pick out the same component from each triple of samples, as you require.

timday
Oh my God..... I can't believe that works! It sort of splits the image in half, and one side grainier than the other, but it works.
Mark
Could be something to do with the precision with which 1.0/3.0 is maintained internally (especially if it works OK up to a certain size). I'd suggest adjusting the ratio very slightly or using a 4-bytes-per-pixel format and a zoom factor of 0.25.
timday