LAnnAutomation::SetAutoHilightPen

#include "ltwrappr.h"

virtual L_INT LAnnAutomation::SetAutoHilightPen(crHilight)

COLORREF crHilight;

/* the color of the pen that is used for highlighting */

Sets the color of the pen that is used for highlighting.

Parameter

Description

crHilight

The color of the pen that is used for highlighting.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function allows you to change the color of the pen that is used for highlighting and selecting. More specifically, this pen is used in the following situations:

The highlighting is implemented by taking the "exclusive-or" (XOR) of the highlight pen color and the underlying image pixels.

The default highlight pen has a COLORREF value of 0xFFFFFF (white). This color works well for most images. However, images that have many mid-range gray colors will not effectively show a highlight.

To understand why this is so, consider an image that contains only the color gray 0x808080. The highlight color will be determined as follows:

 Highlight Color  = (0xFFFFFF) XOR (0x808080)

   = 0x7F7F7F

The highlight color (0x7F7F7F) (gray) and the underlying image color (0x808080) (gray) are almost the same color, and nearly indistinguishable to the naked eye. In cases like this, the highlight will not be visible.

To avoid this, choose a different highlight pen color so that XOR operation with the underlying color will give a result that is visibly different from the underlying color. A good choice is 0xC0C0C0 (silver). Using this color the highlight color will be determined as follows:

Highlight Color = (0xC0C0C0) XOR (0x808080)

   = 0x404040

The resulting highlight color (0x404040) is another gray, but is more visible and stands out much more clearly against the underlying image color (0x808080), allowing for easy differentiation between the two.

Note: several of the automated mode annotation cursors are displayed using an XOR operation. For images with many mid-range grays, these cursors will not be visible. To avoid this, define your own cursors and use the LAnnAutomation::SetAutoCursor function. The main annotation demo (ClAnno32.EXE) demonstrates how to change the highlight pen and the annotation cursors.

Required DLLs and Libraries

LTANN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LAnnotation::GetAutoBackColor, LAnnotation::GetBackColor, LAnnotation::SetBackColor, LAnnAutomation::SetAutoCursor, Class Members, LAnnotation::GetFillMode, LAnnotation::SetFillMode, LAnnotation::GetOptions, LAnnotation::SetOptions, LAnnAutomation::GetAutoHilightPen

Topics:

Annotation Functions: Object Properties

 

Implementing Annotations

 

Implementing Custom Annotations

 

Automated User Interface for Annotations

 

Annotation Functions: Creating and Deleting Annotations

 

Types of Annotations

 

Annotation Functions: Creating Custom Annotations

 

Fixed Annotations

 

Minimizing Flicker With Double Buffering

 

Annotation Functions: Working with the Toolbar

 

Color Halftones and Halftone Images

 

Raster Image Functions: Working with Color Halftones, Halftones, and Grayscale Images

Example

class CBitmapWindow : public LBitmapWindow
{
private:
      LAnnContainer* m_pContainer;
      LAnnAutomation *m_pAutomation;
      LAnnToolBar *m_pToolBar;
public:
   CBitmapWindow()
   {
      m_pContainer = NULL;
      m_pAutomation = NULL;
   }
   ~CBitmapWindow()
   {
   }
   L_VOID SetContainer(LAnnContainer * pContainer)
   {
      m_pContainer = pContainer;
   }
   L_VOID SetAutomation(LAnnAutomation * pAutomation)
   {
      m_pAutomation = pAutomation;
   }
   L_VOID SetToolBar(LAnnToolBar * pToolBar)
   {
      m_pToolBar = pToolBar;
   }
};
LAnnContainer  m_LeadAContainer;
LAnnToolBar    m_LeadAToolbar;
LAnnAutomation m_LeadAAutomation;
CBitmapWindow  m_LBitmap;
void InitState(HWND hParent)
{
   LSettings::LoadLibraries(LT_ALL_LEADLIB);
   LSettings::UnlockSupport(L_SUPPORT_DOCUMENT, L_KEY_DOCUMENT);
   
   CRect rcRect(0, 0, 100, 100);
   // Create the LBitmapWindow control, make it visible, and make it center the image
   HWND hWnd = m_LBitmap.CreateWnd(hParent, 
                                   901, 
                                   WS_VISIBLE,
                                   rcRect.TopLeft().x,
                                   rcRect.TopLeft().y,
                                   rcRect.BottomRight().x,
                                   rcRect.BottomRight().y);
   int nRet = 0;
   RECT rcClientArea;
   ANNRECT rcContainerRect;
   nRet = m_LBitmap.Load(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\image1.cmp"));
   if(nRet == SUCCESS)
   {
      ::GetClientRect(hWnd,&rcClientArea);
      m_LBitmap.SetDstRect(&rcClientArea);
      rcContainerRect.left = 0;
      rcContainerRect.top = 0;
      rcContainerRect.right = rcClientArea.right-rcClientArea.left;
      rcContainerRect.bottom = rcClientArea.bottom-rcClientArea.top;
      m_LeadAContainer.Create(hWnd,&rcContainerRect,TRUE);
      m_LeadAContainer.SetOffsetX((L_DOUBLE) 0, 0);
      m_LeadAContainer.SetOffsetY((L_DOUBLE) 0, 0);
      m_LeadAAutomation.Create();
      /* Assign the automation object to the container */
      m_LeadAAutomation.SetAutoContainer(&m_LeadAContainer);
      /* Enable the automation object */
      m_LeadAAutomation.SetActiveState(ANNACTIVE_ENABLED);
      /* Set design mode, which allows creation of annotations */
      m_LeadAContainer.SetUserMode();
      /* Set the dots per inch for interpreting physical measurements */
      //m_LeadAContainer.SetDpiX(600, 0);
      m_LeadAContainer.SetDpiY(600, 0);
      /* Set the number of possible undo actions */
      m_LeadAAutomation.SetUndoDepth(3);
      /* Set the line tool as the initial annotation tool */
      m_LeadAToolbar.Create(hParent, NULL, ANNTOOLALIGN_RIGHT | ANNTOOLALIGN_TOP, TRUE);
      m_LBitmap.SetContainer(&m_LeadAContainer);
      m_LBitmap.SetAutomation(&m_LeadAAutomation);
      m_LBitmap.SetToolBar(&m_LeadAToolbar);
   }
}
L_INT LAnnAutomation_SetAutoHilightPenTest(L_BOOL bAnnHilightPen)
{
   m_LeadAAutomation.SetAutoHilightPen(bAnnHilightPen ? RGB(0xC0, 0xC0, 0xC0) : RGB(0xFF, 0xFF, 0xFF));
   return SUCCESS;
}