Creating a Bitmap Region Inside the Image Viewer

A bitmap region is an area of interest within a bitmap. A bitmap can have only one region at a time, but the region can be complex, including, for example, multiple noncontiguous shapes.

When a bitmap has a region, the LEADTOOLS functions that modify the pixel values act on the region, rather than the whole bitmap. In addition, the LEADTOOLS functions that flip, reverse, rotate, shear, or resize a bitmap also transform the region to match the bitmap. For example, if you were to shear a bitmap that had a rectangular region, the region would become a parallelogram.

By default, a bitmap does not have a region. You create a bitmap region whenever you perform one or more of the following actions:

Features of Version 16 and above:

For more information on how to use Image Viewer actions, refer toLImageViewerCell::AddAction and LImageViewerCell::SetAction.

To set a bitmap region handle, use the LImageViewerCell::SetCellRegionHandle function. Retrieve a copy of the region handle for a specified bitmap in a specified cell use the LImageViewerCell::GetCellRegionHandle function. To save the region of a specified cell or sub-cell image to a file, use the LImageViewerCell::SaveRegion function. To load a region page saved by the LImageViewerCell::SaveRegion function use the LImageViewerCell::LoadRegion function.

Features of Version 15 and above:

Each time you create a region using one of the container actions, you need to specify how the new region is to be added to the existing bitmap region (if there is one). This can be done programmatically using the LImageViewer::SetActionProperties function, or through the interface using keyboard shortcuts, as follows:

Value of the uOperation member of the DISPREGIONPROPS structure that is set or retrieved using the LImageViewerCell::SetActionProperties or LImageViewerCell::GetActionProperties functions:

(Image Viewer) Keyboard shortcut

Description

L_RGN_AND

Ctrl + Alt

[0] The resulting region includes only the intersection of the existing region and the new one. The following example shows the result, where the rectangles represent the existing region, the ellipse represents the new one, and the shaded area represents the resulting region.

 

 

image\ukn_rand.gif

L_RGN_SET

None

[1] The resulting region includes only the new region. The existing region, if any, is discarded. The following example shows the result, where the ellipse is the new region and the shaded area is the resulting region.

 

 

image\ukn_rset.gif

L_RGN_SETNOT

Ctrl + Alt if there is no existing region. 

[6] The resulting region includes everything in the bitmap, except the new region. The existing region, if any, is discarded. The following example shows the result, where the ellipse is the new region and the shaded area is the resulting region.

 

 

image\ukn_rsetnot.gif

L_RGN_ANDNOTBITMAP

N/A

[2] The resulting region includes the intersection of the area outside the existing region and the area inside the new region. The following example shows the result, where the rectangle is the existing region, the ellipse is the new one, and the shaded area is the resulting region.

 

 

image\ukn_randnotb.gif

L_RGN_ANDNOTRGN

Alt

[3] The resulting region includes the intersection of the area inside the existing region and the area outside the new region. The following example shows the result, where the rectangle is the existing region, the ellipse is the new one, and the shaded area is the resulting region.

 

 

image\ukn_randnotr.gif

L_RGN_OR

Shift

[4] The resulting region includes the area inside the existing region and the area inside the new region. The following example shows the result, where the rectangle is the existing region, the ellipse is the new one, and the shaded area is the resulting region.

 

 

image\ukn_ror.gif

L_RGN_XOR

N/A

[5] The resulting region includes the area inside the existing region and the area inside the new region, except for any areas where the two intersect. The following example shows the result, where the rectangle is the existing region, the ellipse is the new one, and the shaded area is the resulting region.

 

 

image\ukn_rxor.gif

Working with the LEADTOOLS Medical Image Viewer Control

Using the Medical Image Viewer Control

Image Viewer Cells

Applying Actions

Creating a Bitmap Region Inside the Image Viewer

Implementing Animation

Working with Annotations

Customizeable Title Bar

For more information, refer to:

Introduction

Example Programs

Summary of All Supported Image File Formats

See Also:

Microsoft Code Snippet Picker

LEADTOOLS Support Forums

LEADTOOLS Medical Imaging Support Forum