LRasterPaint::SetTransformation

#include "Ltwrappr.h"

L_INT LRasterPaint::SetTransformation(pXForm)

pPAINTXFORM pXForm;

/* pointer to a PAINTXFORM structure */

Sets the toolkit transformation information.

Parameter

Description

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:

LRasterPaint::GetTransformation, LRasterPaint::GetDCExtents, LRasterPaint::SetDCExtents, LRasterPaint::SetMetrics, Class Members

Topics:

Setting General DigitalPaint Information

Example

L_INT OnPaintShape ( CWnd* pWnd, LBitmap* pBitmap )
{
   //data member L_INT m_nZoomFactor = 500 ;
   //data member L_INT m_nHscroll    = 0 ;
   //data member L_INT m_nVscroll    = 0 ;

   LRasterPaint rstp ;
   CDC*   pDC = pWnd->GetDC() ;

   RECT    rcView ;
   L_INT   nXOffset, nYOffset ;
   RECT   rcShapeRect ;
   PAINTXFORM   PntXForm ;

   /* Initiate the Paint toolkit */
   if ( SUCCESS != rstp.Initialize (  )  )
   {
            return FAILURE ; 
   }

   /* set the painting rectangel */
   SetRect ( &rcView, 0, 0, pBitmap->GetWidth() , pBitmap->GetHeight() ) ;
   
   if ( m_nZoomFactor < 100 )
   {
      nXOffset = - MulDiv ( m_nHscroll, 100, m_nZoomFactor ) ;  
      nYOffset = - MulDiv ( m_nVscroll, 100, m_nZoomFactor ) ;
   }
   else
   {
      nXOffset = - m_nHscroll ;  
      nYOffset = - m_nVscroll ;
   }

   OffsetRect ( &rcView, nXOffset, nYOffset ) ;
   
   rcView.left   = MulDiv ( rcView.left,   m_nZoomFactor, 100 ) ;
   rcView.top    = MulDiv ( rcView.top,    m_nZoomFactor, 100 ) ;
   rcView.right  = MulDiv ( rcView.right,  m_nZoomFactor, 100 ) ;
   rcView.bottom = MulDiv ( rcView.bottom, m_nZoomFactor, 100 ) ;
   
   // set the paintin transformatoins values.
   PntXForm.nZoom    = m_nZoomFactor ;
   PntXForm.nXOffset = - rcView.left ;
   PntXForm.nYOffset = - rcView.top ;

   /* Set the painting transformations to reflect a zoom-in by 5:1 */
   rstp.SetTransformation ( &PntXForm ) ; 

   /* paint the bitmap */
   pBitmap->Paint()->SetDC( pDC->m_hDC );
   pBitmap->SetDstRect( &rcView );
   pBitmap->Paint()->PaintDC();

   /* 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) */
   rstp.DrawShapeRectangle ( pDC->m_hDC, &rcShapeRect ) ;

   /* Release the device context */
   pWnd->ReleaseDC( pDC ) ;

   /* Free the paint tools handle */
   rstp.Free ( ) ;

   return SUCCESS ;
}