This topic describes how to let the user select an area with a mouse and zoom in on the selected area. In this topic, you learn the following:
How to use the source rectangle with the L_PaintDC function.
How to translate client area coordinates to bitmap coordinates, while accounting for differences in view perspective. For general information about view perspectives, refer to Accounting for View Perspective.
To be as simple and specific as possible, these instructions describe how to modify the EZFUNC example program. If you want to test the sample code, you should make a copy of the EZFUNC program, and modify the copy. The display rectangles used in this program are described in Fitting an Image to a Window.
Step 1 On WIN32 systems, include the GDI library so that we can display an outline of the selection.
Step 2 Modify the EZFUNC.H file to add global variables for tracking coordinates.
Step 3 In the MainWndProc function, add some new local variables to support the GDI functions.
Step 4 In the MainWndProc function, add code to process WM_LBUTTONDOWN messages. This code initializes coordinates for defining two rectangles. One rectangle is relative to the client area and is used with the GDI functions to outline the selection. The other rectangle is relative to the bitmap and is used to zoom in by defining the source rectangle for painting.
Step 5 In the MainWndProc function, add code to process WM_MOUSEMOVE messages. This code outlines the selection using GDI functions.
Step 6 In the MainWndProc function, add code to process WM_LBUTTONUP messages. This code defines the source and destination rectangles for painting, and forces a repaint.
Step 7 In the MainWndProc function, add code to process WM_RBUTTONDOWN messages. This code returns to the display of the full image when the user clicks the right mouse button.
The following topics provide detailed descriptions of these steps, with code that you can copy from the online help and paste into the sample program.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document