Creating a Custom Fill Pattern

To create a custom fill pattern that the operating system will use to fill area primitives and paths:

The following figure shows how to create the pattern.

    /* Define an array of bytes;  this array creates a grid pattern. */
    BYTE abPattern5[] = {
        0xFF, 0xFF, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00,
        0x80, 0x00, 0x00, 0x00 };

        LONG lcidCustom = 1;
    HPS hps;
    PBITMAPINFO2 pbmi;
    BITMAPINFOHEADER2 bmp;
    HBITMAP hbm;
    PRGB2 prgb2;

    /* Create the bit map, passing the address of the array of bytes. */
    hbm = GpiCreateBitmap(hps, &bmp, CBM_INIT, (PBYTE) abPattern5, pbmi);

    /* Assign a local identifier to the bit map.                      */
    GpiSetBitmapId(hps, hbm, lcidCustom);

    /* Set the pattern-set attribute in the AREABUNDLE structure.     */
    GpiSetPatternSet(hps, lcidCustom);


[Back: Scaling and Drawing a Bit-Map Image]
[Next: Loading a Bit Map from a File]