Zooming through a User Interface

The BiDisp DLL or OCX include functions or methods to zoom the image with user interaction. The user can select a rectangle on the image for zooming.

 

[C++]

 

#include “BiDisp.h”

 

/* You have to redefine some functions in CView class for zooming */

 

void CMyView::OnLButtonDown(UINT nFlags, CPoint point)

{

         …

         ZOOMFLAG zmflg = ZOOM_SELECT_LARGE;

         if(nFlags & MK_CONTROL)

            zmflg = ZOOM_SELECT_MOVE;

         if(nFlags & MK_SHIFT)

            zmflg = ZOOM_SELECT_PLUS;

         // Inicialize zoom

         // 1. parameter (HWND): Window handle to display image

         // 2. parameter (LPPOINT): Coordinates of the mouse pointer

         // 3. parameter (LPRECT): X, Y scaling factor

         // 4. parameter (ZOOMFLAG): Determines the operation of zoom.

         // 5. parameter (LPZOOMSTRUCT): Zoom structure

         // 6. parameter (BOOL): Inerpretation of mouse pointer coordanates

         BZoomStart(m_hWnd, &point, &rScale, zmflg, &m_zm, FALSE);

         m_zoom_select = TRUE;

         …

}

 

void CMyView::OnMouseMove(UINT nFlags, CPoint point)

{

         …

         if (m_zoom_select)

            // 1. parameter (HWND): Window handle to display image

            // 2. parameter (LPPOINT): Coordinates of the mouse pointer

            // 3. parameter (LPZOOMSTRUCT): Zoom structure

            BZoomUpdate(m_hWnd, &point, &m_zm);

         …

}

 

void CVtiffView::OnLButtonUp(UINT nFlags, CPoint point)

{

         …

         if(m_zoom_select)

         {

            // 1. parameter (HWND): Window handle to display image

            // 2. parameter (LPPOINT): Coordinates of the mouse pointer

            // 3. parameter (LPZOOMSTRUCT): Zoom structure

            // 4. parameter (DISPLAYSTRUCT): Display information structure

            BZoomEnd(m_hWnd, &point, &m_zm, &sDisplay);

            DispZoom();

         }

         …

}

 

void CMyView::DispZoom()

{

         CopyRect(&rScale, &m_zm.rScaleOut);

         SetRect(&sDisplay.rOrigo, 0, 0, 0, 0);

         sDisplay.rOrigo.left  = m_zm.pOrigoOut.x;

         sDisplay.rOrigo.top   = m_zm.pOrigoOut.y;

 

         if(hDib)

         {

            DisplayDIBStart(m_hWnd, hDib, &sDisplay.rOrigo,

                        &rScale, wDisplayMode, &sDisplay);

         }

}

 

[VB]

 

Private Sub mnuZoom_Click()

            ‘ Set Zoom property to True

            BiDisp.Zoom = 1

End Sub

 

[C#]

 

private void ZoomImage()

{

            // Set Zoom property to true

            BiDisp.Zoom = BIDISPLib.enum2State.tif2sEnable;

}