How to highlight selected area of an image

Scenario:

There are occasions that customers want to highlight parts of an image. Dynamic Web TWAIN supports that feature with the OverlayRectangle method.

Solution:

In the following paragraphs, we will introduce how to do this:

  • Select the area
// Use OnImageAreaSelected event to choose the area you want to 
highlight: 
function Dynamsoft_OnImageAreaSelected(index, left, top, right, bottom) { 
  _iLeft = left;
  _iTop = top;
  _iRight = right;
  _iBottom = bottom; } 
// Use OnImageAreaDeselected event to cancel the selection: 
function Dynamsoft_OnImageAreaDeselected(index) { 
  _iLeft = 0;
  _iTop = 0; 
  _iRight = 0; 
  _iBottom = 0; }
  • Highlight the area (here we are adding a gray rectangle)

 

DWObject.OverlayRectangle(
    DWObject.CurrentImageIndexInBuffer,
    _iLeft, _iTop, _iRight, _iBottom, 0x000000/*Int32 ColorRGB*/, 0.5/*Single Opacity*/
);

Int32 ColorRGB: Specifies the fill color of the rectangle. The byte-ordering of the RGB value is 0xBBGGRR. BB represents blue, GG represents green, RR represents red.
Single Opacity: Specifies the opacity of the rectangle. The value represents opacity. 1.0 is 100% opaque and 0.0 is totally transparent.

Is this page helpful?

Leave a Reply

Your email address will not be published.