views:

267

answers:

2

Hi, i'm wondering how a array of 32x32 is mapped to a bitmap. The following arrays represents a bitmap. I know that each row of the array represents row of the bitmap. The first row of the array is the last row of the bitmap, and so on, up to the last row of the array that is the first row of the bitmap, but how this works?

GLubyte myInitial[] = {
    0xff, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0xff, 0x01, 0xff, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0xff, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};
+1  A: 

Each input byte consists of 8 bits. While rendering the pattern is tiled across the triangle surface. Wherever the pattern has a 1 bit the pixel will be drawn.

See the documentation, as well as an example.

genpfault
Triangular surface?
Charles Stewart
@Charles, The shape or viewing angle of the surface does not matter. The stipple is applied at the pixel level.
Mike Daniels
@Mike: Sure, but the shape at decoding must match the shape at encoding.
Charles Stewart
+2  A: 

That stipple pattern isn't formatted that well. It should look like this:

0xff, 0x01, 0x00, 0x01,  // #########               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0xff, 0x01, 0xff, 0x01,  // #########       #########       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0xff, 0x00, 0xFF, 0x01,  // ########         ########       
0x00, 0x00, 0x00, 0x00,  //
0x00, 0x00, 0x00, 0x00,  //
0x00, 0x00, 0x00, 0x00   //

That is a 32x32 1-bit-per-pixel bitmap. As you can see, if you were to draw a 32x32 pixel screen quad in white on a black background it would render PE.

MSN