Using the Magnifying Glass

LEADTOOLS provides a "magnifying glass" that can be attached to a window handle. This magnifying glass provides a means of "zooming in" on the image loaded into the window to which it is attached.

Use the "Magnifying Glass" if you want to:

image\sqrblit.gif Work with the magnifying glass after passing a callback function to the L_StartMagGlass function; the optional callback is used to handle the WM_LBUTTONDOWN, WM_LBUTTONUP and WM_MOUSEMOVE messages received by the window to which the Magnifying Glass is attached.

image\sqrblit.gif Set the contrast, gamma and intensity for the zoomed area.

Note that in the Document/Medical toolkits LEADTOOLS also provides a "Zoom View" that can be attached to a window handle.

Use the "Zoom View" if you want to:

image\sqrblit.gif Display one or more zoomed views for a single displayed image.

image\sqrblit.gif Display an annotation in addition to the zoomed view.

image\sqrblit.gif Display callout lines.

For more information about the Zoom View, refer to Using the Zoom View.

To attach the magnifying glass to a window, call L_StartMagGlass or L_StartMagGlass. To determine whether a window has a magnifying glass attached to it, call the L_WindowHasMagGlass function. As the magnifying glass is moved over an image, the zoomed - in view is also displayed.

One of three scenarios can be followed when working with magnifying glass:

1.

Work with an ordinary magnifying glass that will be attached to the window and there is no need to write any code to show the magnifying glass or to move it over the image, since this will be handled internally by LEADTOOLS. This scenario can be achieved through calling L_StartMagGlass function but without passing a callback function or setting the MAGGLASS_MANUAL_UPDATE flag.

2.

Work with the magnifying glass after passing a callback function to the L_StartMagGlass function; the optional callback is used to handle the WM_LBUTTONDOWN, WM_LBUTTONUP and WM_MOUSEMOVE messages received by the window to which the Magnifying Glass is attached. The passed callback function will receive information when the left mouse button is pressed or released and when the mouse is moved. While the left mouse button is pressed, this information represents the needed pixel colors of the Bitmap parts that the magnifying glass is over it now (Also it is called the non-updated parts of the bitmap). Low-level functions like L_GetPixelColor can then be used to get color information for the non-updated parts of the bitmap. This callback works more efficiently when working with a Client/Server model, available in the Multimedia/Internet toolkits, and using Internet functions to get the needed information. This new color information can then be passed to L_UpdateMagGlass to update the Magnifying Glass zoomed image. The user is involved in this scenario by passing the needed pixel colors by calling the L_UpdateMagGlass function.

 

If a callback function is passed to L_StartMagGlass, L_UpdateMagGlass must be called in order to paint the zoomed image in the Magnifying Glass display area.

3.

If the MAGGLASS_MANUAL_UPDATE flag was passed to the L_StartMagGlass function, the user will be responsible for handling WM_LBUTTONDOWN, WM_LBUTTONDBLCLK, WM_LBUTTONUP, WM_MOUSEMOVE, WM_SETCURSOR and WM_KILLFOCUS messages instead of handling them internally by LEADTOOLS.

 

L_ShowMagGlass, L_SetMagGlassPos and L_UpdateMagGlassBitmap functions can be used only when manually updating the Magnifying Glass. L_ShowMagGlass function will show or hide the Magnifying Glass, while the L_SetMagGlassPos function will move the Magnifying Glass to a specified position. The L_UpdateMagGlassBitmap function can be used to update the bitmap that the Magnifying Glass displays in the zoomed display area.

The following can be set using the L_StartMagGlass function:

image\sqrblit.gif size of the magnifying glass

image\sqrblit.gif shape of the magnifying glass

image\sqrblit.gif magnifying glass border (color, thickness, appearance)

image\sqrblit.gif magnification level

image\sqrblit.gif size of the rectangle used to display the zoomed image

image\sqrblit.gif paint characteristics

image\sqrblit.gif section of the pixel on which to center the zoomed image

image\sqrblit.gif color masks

To update the Magnifying Glass procedure with a new destination rectangle, call L_UpdateMagGlassRect. This should be done anytime the image’s destination rectangle is modified, for example, when scrolling or zooming.

To update the Magnifying Glass procedure with new display flags, call L_UpdateMagGlassPaintFlags.

The L_StartMagGlass function lets you set all of the previously listed properties as well as the following:

image\sqrblit.gif flags that indicate which colors in the bitmap to display and which to mask

image\sqrblit.gif flags that enable or disablethe manual updating of the magnifying glass

image\sqrblit.gif an optional callback to handle the WM_LBUTTONDOWN, WM_LBUTTONUP and WM_MOUSEMOVE messages received by the window to which the Magnifying Glass is attached.

If a callback function is passed to L_StartMagGlass, information about the non-updated parts of the bitmap can be obtained from the callback function. Low-level functions like L_GetPixelColor can then be used to get color information for the non-updated parts of the bitmap. This new color information can then be passed to L_UpdateMagGlass to update the Magnifying Glass zoomed image. This callback function receives information when the left mouse button is pressed or released and when the mouse is moved while the left mouse button is pressed.

If a callback function is passed to L_StartMagGlass, L_UpdateMagGlass must be called in order to paint the zoomed image in the Magnifying Glass display area.

LEADTOOLS provides two defined shapes for the Magnifying Glass: Rectangle and Ellipse. The L_UpdateMagGlassShape function lets you update the shape of the magnifying glass to one of the previously listed shapes, or to a custom shape.

L_SetMagGlassPaintOptions gives the user the ability to set the contrast, gamma and intensity for the zoomed area.

after L_StartMagGlass has been called and the Magnifying Glass paints itself to the DC, but before the Magnifying Glass is displayed on the screen, the user can change what is in the DC, through a user-defined callback function of the MAGGLASSOWNERDRAWCALLBACK prototype. In order to use this callback function, the callback function must be set by calling L_SetMagGlassOwnerDrawCallback. This feature lets you render magnified annotations, which may be overlaid on the currently displayed image, or just simply override what is currently in the Magnifying Glass display area.

To discontinue using the MAGGLASSOWNERDRAWCALLBACK to render the Magnifying Glass, call L_SetMagGlassOwnerDrawCallback a second time, with the pfnCallback parameter set to NULL.

When the magnifying glass is no longer needed, call L_StopMagGlass to stop the magnifying glass procedure and to detach it from the window handle.