Scaling and Drawing a Bit-Map Image

You can scale a bit map by calling GpiBitBlt or GpiWCBitBlt and altering the dimensions of the target rectangle. The following figure shows how to shrink the screen copied in the first example to half its original size, and then redraw it by calling GpiBitBlt.

    POINTL aptl[3];
    HPS hpsMem, hps;
    HWND hwnd;
    SHORT sWidth = 128, sHeight = 128;
    /* Target-rectangle dimensions (in device coordinates)              */
    aptl[0].x = 0;
    aptl[0].y = 0;
    aptl[1].x = sWidth / 2;
    aptl[1].y = sHeight / 2;

    /* Source-rectangle dimensions (in device coordinates)              */
    aptl[2].x = 0;
    aptl[2].y = 0;
    aptl[3].x = sWidth;
    aptl[3].y = sHeight;

    hps = WinGetPS(hwnd);

    GpiBitBlt(hps, hpsMem,
        sizeof(aptl) / sizeof(POINTL),      /* Number of points in aptl */
        aptl, ROP_SRCCOPY, BBO_IGNORE);

    WinReleasePS(hps);


[Back: Copying an Image from a Display Screen to a Bit Map]
[Next: Creating a Custom Fill Pattern]