裁剪輸出
使用者按一下功能表中的 [剪輯] 之後,應用程式會使用使用者建立的矩形座標來定義裁剪區域。 定義裁剪區域並將其選取至應用程式的裝置內容之後,應用程式會重新繪製點陣圖影像。 應用程式會執行這些工作,如下所示。
// These variables are required for clipping.
static POINT ptUpperLeft;
static POINT ptLowerRight;
static POINT aptRect[5];
static POINT ptTmp;
static POINTS ptsTmp;
static BOOL fDefineRegion;
static BOOL fRegionExists;
static HRGN hrgn;
static RECT rctTmp;
int i;
case WM_COMMAND:
switch (wParam)
{
case IDM_CLIP:
hdc = GetDC(hwnd);
// Retrieve the application's client rectangle and paint
// with the default (white) brush.
GetClientRect(hwnd, &rctTmp);
FillRect(hdc, &rctTmp, GetStockObject(WHITE_BRUSH));
// Use the rect coordinates to define a clipping region.
hrgn = CreateRectRgn(aptRect[0].x, aptRect[0].y,
aptRect[2].x, aptRect[2].y);
SelectClipRgn(hdc, hrgn);
// Transfer (draw) the bitmap into the clipped rectangle.
BitBlt(hdc,
0, 0,
bmp.bmWidth, bmp.bmHeight,
hdcCompatible,
0, 0,
SRCCOPY);
ReleaseDC(hwnd, hdc);
break;
}