L_PntSetTransformation

#include "LtPnt.h"

L_LTPNT_API L_INT 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 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 ) ;

   /* 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 ;
}