Zooming In on a Selection

If you are using the high-level LBitmapWindow (or derived) class, zooming in on a selection is done automatically for you when you set the tool to TOOL_ZOOMRECT using LBitmapWindow::SetToolType. The class object will automatically handle the mouse events for you, and adjust the bitmap's display rectangles in order to zoom in on the user-defined rectangle.

If you are not using LBitmapWindow, 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 LPaint::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.

  1. Add this code to load an image and initialize the display rectangles.

  2. Add these global variables for tracking coordinates to your program.

  3. Add this 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.

  4. Add this code to process WM_MOUSEMOVE messages. This code outlines the selection using GDI functions.

  5. Add this code to process WM_LBUTTONUP messages. This code defines the source and destination rectangles for painting, and forces a repaint (CalcDisplay is defined below).

  6. Add this code to process WM_RBUTTONDOWN messages. This code returns to the display of the full image when the user clicks the right mouse button.

  7. Add this code to process WM_PAINT messages. This code sets the bitmap rectangles and paints the image.

Related Topics

Zooming In on a Selection: Step 1
Zooming In on a Selection: Step 2
Zooming In on a Selection: Step 3
Zooming In on a Selection: Step 4
Zooming In on a Selection: Step 5
Zooming In on a Selection: Step 6
Zooming In on a Selection: Step 7
Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.