L_PntSetTransformation

#include "LtPnt.h"

L_INT EXT_FUNCTION L_PntSetTransformation(pPaint, pXForm)

pPAINTHANDLE pPaint;

/* pointer to a paint handle */

pPAINTXFORM pXForm;

/* pointer to a structure */

Sets the transformation information for the toolkit.

Parameter

Description

pPaint

Pointer to a paint handle.

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

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

LTPNT

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_PntGetTransformation, L_PntGetDCExtents, L_PntSetDCExtents, L_PntSetMetrics

Topics:

DigitalPaint Functions: Transforming External Coordinates

 

Setting General DigitalPaint Information

Example

L_INT g_nZoomFactor = 500 ;
L_INT g_nHScroll = 0 ; /* current scroll bar horzontal value */
L_INT g_nVScroll = 0 ; /* current scroll bar vertical value */
L_INT OnPaintShape ( HWND hWnd, pBITMAPHANDLE pBitmap )
{
   pPAINTHANDLE pPaint ;
   HDC          hDC;
   RECT         rcView ;
   L_INT        nXOffset, nYOffset ;
   RECT         rcShapeRect ;
   PAINTXFORM   PntXForm ;
   
   /* Initiate the Paint toolkit */
   if ( SUCCESS != L_PntInit ( &pPaint ) )
   {
         return FAILURE ; 
   }

   /* 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 */
   L_PntSetTransformation ( pPaint, &PntXForm ) ; 

   /* Get the device context */
   hDC = GetDC ( hWnd ) ;

   /* paint the bitmap */
    L_PaintDC( hDC, pBitmap, NULL, NULL, &rcView, NULL, SRCCOPY ) ;

   /* Set the rectangle coordinates with respect to the DC dimensions*/
   SetRect ( &rcShapeRect, 10, 10, 150, 150 ) ;

   /* Use the current shape properties to draw a rectangle to DC (hDC) */
  L_PntDrawShapeRectangle ( pPaint, hDC, &rcShapeRect ) ;
   
   /* Release the device context */
   ReleaseDC ( hWnd, hDC ) ;

   /* Free the paint tools handle */
   L_PntFree ( pPaint ) ;

   return SUCCESS ;
}