如,我要把一个 rect内的红色替换成黑色。红色区域不规则,如何实现呢?

解决方案 »

  1.   

    FillRgn
    The FillRgn function fills a region by using the specified brush. BOOL FillRgn(
      HDC hdc,    // handle to device context
      HRGN hrgn,  // handle to region to be filled
      HBRUSH hbr  // handle to brush used to fill the region
    );
      

  2.   

    HRGN hrgn
    怎么算呀?例如我现在直到一块大区域 rt0, 它上面是2块小区域,不规则,rt1,rt3,怎么求剩下的不规则的区域的HRGN 
      

  3.   

    int CombineRgn(
    HRGN hrgnDest, 
    HRGN hrgnSrc1, 
    HRGN hrgnSrc2, 
    int fnCombineMode
    ); 
    RGN_AND Creates the intersection of the two combined regions. 
    RGN_COPY Creates a copy of the region identified by hrgnSrc1. 
    RGN_DIFF Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. 
    RGN_OR Creates the union of two combined regions. 
    RGN_XOR Creates the union of two combined regions except for any overlapping areas.用红色那个即可 
      

  4.   

    可以先建两DC
    一个是你的DC1,一个是全黑的DC2
    用::TransparentBlt(DC2 ,...,DC1 ,...,RGB(红))贴图