在一个客户区域内,显示一张图,我画一个椭圆或者一个多边形,怎么把这个区域以外的填充为黑色????
谢谢各位大虾

解决方案 »

  1.   

    你说的是遮罩吧,
    BOOL BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop );dwRopSpecifies the raster operation to be performed. Raster-operation codes define how the GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. The following lists raster-operation codes for dwRop and their descriptions: BLACKNESS   Turns all output black.
    DSTINVERT   Inverts the destination bitmap.
    MERGECOPY   Combines the pattern and the source bitmap using the Boolean AND operator.
    MERGEPAINT   Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator.
    NOTSRCCOPY   Copies the inverted source bitmap to the destination.
    NOTSRCERASE   Inverts the result of combining the destination and source bitmaps using the Boolean OR operator.
    PATCOPY   Copies the pattern to the destination bitmap.
    PATINVERT   Combines the destination bitmap with the pattern using the Boolean XOR operator.
    PATPAINT   Combines the inverted source bitmap with the pattern using the Boolean OR operator. Combines the result of this operation with the destination bitmap using the Boolean OR operator.
    SRCAND   Combines pixels of the destination and source bitmaps using the Boolean AND operator.
    SRCCOPY   Copies the source bitmap to the destination bitmap.
    SRCERASE   Inverts the desination bitmap and combines the result with the source bitmap using the Boolean AND operator.
    SRCINVERT   Combines pixels of the destination and source bitmaps using the Boolean XOR operator.
    SRCPAINT   Combines pixels of the destination and source bitmaps using the Boolean OR operator.
    WHITENESS   Turns all output white. 
      

  2.   

    源代码见http://blog.csdn.net/jmshl/
      

  3.   

    先在pDC里显示图片,再加下面的```就可以了`
    pDC->BeginPath();
    pDC->Ellipse(0,0,650,300);
    pDC->EndPath();
    pDC->SelectClipPath(RGN_XOR);
    pDC->SelectStockObject(BLACK_BRUSH);
    CRect rect;
    GetClientRect(&rect);
    pDC->Rectangle(&rect);