L_PntSetTransformation

#include "LtPnt.h"

L_LTPNT_API L_INT L_PntSetTransformation(pPaint, pXForm)

Sets the transformation information for the toolkit.

Parameters

pPAINTHANDLE pPaint

Pointer to a paint handle.

pPAINTXFORM pXForm

Pointer to a PAINTXFORM structure that contains transform values used to transform input coordinates. If this parameter is NULL, the zoom will default to 100 and the offset values will default to 0.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The toolkit will transform all input and output coordinates, using the values set by this function, unless otherwise stated.

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT PntSetTransformationExample(HWND          hWnd, 
                                                    pBITMAPHANDLE pBitmap, 
                                                    L_INT *g_nZoomFactor, 
                                                    L_INT *g_nHScroll, /* current scroll bar horzontal value */ 
                                                    L_INT *g_nVScroll /* current scroll bar vertical value */) 
{ 
   L_INT nRet; 
   pPAINTHANDLE pPaint ; 
   HDC          hDC; 
   RECT         rcView ; 
   L_INT        nXOffset, nYOffset ; 
   RECT         rcShapeRect ; 
   PAINTXFORM   PntXForm ; 
    
   /* Initiate the Paint toolkit */ 
   nRet = L_PntInit ( &pPaint ); 
   if ( SUCCESS != nRet ) 
   { 
         return nRet;  
   } 
 
   /* set the painting rectangel */ 
   SetRect ( &rcView, 0, 0, BITMAPWIDTH ( pBitmap ), BITMAPHEIGHT ( pBitmap ) ) ; 
 
   if ( *g_nZoomFactor < 100 ) 
   { 
      nXOffset = - MulDiv ( *g_nHScroll, 100, *g_nZoomFactor ) ;   
      nYOffset = - MulDiv ( *g_nVScroll, 100, *g_nZoomFactor ) ; 
   } 
   else 
   { 
      nXOffset = - *g_nHScroll ; 
      nYOffset = - *g_nVScroll ; 
   } 
 
   OffsetRect ( &rcView, nXOffset, nYOffset ) ; 
 
   rcView.left   = MulDiv ( rcView.left,   *g_nZoomFactor, 100 ) ; 
   rcView.top    = MulDiv ( rcView.top,    *g_nZoomFactor, 100 ) ; 
   rcView.right  = MulDiv ( rcView.right,  *g_nZoomFactor, 100 ) ; 
   rcView.bottom = MulDiv ( rcView.bottom, *g_nZoomFactor, 100 ) ; 
 
   // set the paintin transformatoins values. 
   PntXForm.nZoom    = *g_nZoomFactor ; 
   PntXForm.nXOffset = - rcView.left ; 
   PntXForm.nYOffset = - rcView.top ; 
 
   /* Set the painting transformations to reflect a zoom-in by 5:1 */ 
   nRet = L_PntSetTransformation ( pPaint, &PntXForm ) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Get the device context */ 
   hDC = GetDC ( hWnd ) ; 
 
   /* paint the bitmap */ 
   nRet = L_PaintDC( hDC, pBitmap, NULL, NULL, &rcView, NULL, SRCCOPY ) ; 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Set the rectangle coordinates with respect to the DC dimensions*/ 
   SetRect ( &rcShapeRect, 10, 10, 150, 150 ) ; 
 
    /* Set the DC Extents */ 
   RECT rcClient; 
   GetClientRect(hWnd, &rcClient); 
   nRet = L_PntSetDCExtents ( pPaint, &rcClient ); 
 
   /* Use the current shape properties to draw a rectangle to DC (hDC) */ 
   nRet = L_PntDrawShapeRectangle ( pPaint, hDC, &rcShapeRect ) ; 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Release the device context */ 
   ReleaseDC ( hWnd, hDC ) ; 
 
   /* Free the paint tools handle */ 
   L_PntFree ( pPaint ) ; 
 
   return SUCCESS ; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Digital Paint C API Help