Setting a DigitalPaint Clipping Region

Clipping is used by the LRasterPaint class to limit the output to a user-defined region. This can be done using the LRasterPaint::SetClipRgn function. To get the last clipping region set, call LRasterPaint::GetClipRgn. To offset a clipping region, call LRasterPaint::OffsetClipRgn.

L_INT OnPaintShape ( HWND hWnd ) 
{ 
   LRasterPaint Paint ; 
   HDC hDC ; 
   HRGN hClipRgn ; 
   RECT rcShapeRect ; 
   /* Initiate the Paint toolkit */ 
   if ( SUCCESS != Paint.Initialize( ) ) 
   { 
      return FAILURE ; 
   } 
   /* Get device context to draw on */ 
   hDC = GetDC ( hWnd ) ; 
   /*Set the rectangle coordinates with respect to the DC dimensions*/ 
   SetRect ( &rcShapeRect, 10, 10, 110, 110 ) ; 
   /*Use the current shape properties to draw an ellipse to DC (hDC) */ 
   Paint.DrawShapeEllipse ( hDC, &rcShapeRect ) ; 
   hClipRgn = CreateRectRgn ( 120, 20, 200, 100 ) ; 
   /*Set painting clip region */ 
   Paint.SetClipRgn ( hClipRgn ) ; 
   /*Set the rectangle coordinates with respect to the DC dimensions*/ 
   SetRect ( &rcShapeRect, 110, 10, 210, 110 ) ; 
   /*Use the current shape properties to draw an ellipse to DC (hDC) */ 
   Paint.DrawShapeEllipse ( hDC, &rcShapeRect ) ; 
   /*Delete the clip region */ 
   DeleteObject ( ( HRGN ) hClipRgn ) ; 
   /*Release the device context */ 
   ReleaseDC ( hWnd, hDC ) ; 
   /* Free the paint tools class object */ 
   Paint.Free ( ) ; 
   return SUCCESS ; 
} 

Help Version 22.0.2021.8.20
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DigitalPaint C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.