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:
CONTAINER_ACTION_REGION_RECTANGLE
CONTAINER_ACTION_REGION_ELLIPSE
CONTAINER_ACTION_REGION_FREEHAND
CONTAINER_ACTION_REGION_POLYGON
CONTAINER_ACTION_REGION_MAGICWAND
CONTAINER_ACTION_REGION_COLORRANGE
CONTAINER_ACTION_REGION_CIRCLE
CONTAINER_ACTION_REGION_SQUARE
For more information on how to use Image Viewer actions, refer to LImageViewer::AddAction and LImageViewer::SetAction.
Each time you create a region using one of these 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 LImageViewer::SetActionProperties or LImageViewer::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. |
|
|
|
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. |
|
|
|
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. |
|
|
|
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. |
|
|
|
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. |
|
|
|
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. |
|
|
|
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. |
|
|