LAnnContainer::EncryptApply

#include "ltwrappr.h"

virtual L_INT LAnnContainer::EncryptApply(uEncryptFlags, uFlags)

Applies an encryptor annotation object to the underlying bitmap.

Parameters

L_UINT uEncryptFlags

Flags that determine which objects to apply. Most of the flags apply only to container objects. You can combine values when appropriate by using a bitwise OR (|). The following are valid values:

Value Meaning
ANNENCRYPTAPPLY_ENCRYPTOR [0x001] Apply encryptor objects
ANNENCRYPTAPPLY_DECRYPTOR [0x002] Apply decryptor objects
ANNAPPLYENCRYPT_BOTH [0x003] Apply both encryptor and decryptor objects

L_UINT uFlags

Flags that determine which objects to process. Most of the flags apply only to container objects. You can combine values when appropriate by using a bitwise OR (|). The following are valid values:

Value Meaning
0 Process only the specified object.
ANNFLAG_SELECTED [0x0001] Process only objects that have the selected property set to TRUE. For getting and setting the selected property, use the LAnnotation::IsSelected and LAnnotation::SetSelected functions.
ANNFLAG_NOTTHIS [0x0004] Process only one level of objects within the specified container, not the container itself. If there are containers within the container, they are modified, but the objects within them are not.
ANNFLAG_RECURSE [0x0008] Process objects within a container, and within any subcontainers, down to any level.
ANNFLAG_NOTCONTAINER [0x0002] (Used with ANNFLAG_RECURSE) Process objects within containers, not the containers themselves.
ANNFLAG_NOINVALIDATE [0x0010] Do not invalidate the affected rectangle in the window. Use this to avoid generating unwanted paint messages.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

An encrypt object can have two states: it can be an encryptor or it can be a decryptor.

Use this function to apply encryptor(s), decryptor(s), or both. Applying an encryptor means that the part of the bitmap that is under the encryptor is scrambled according to the encryptor properties.

Once applied, the portion of the bitmap under the encrypt object becomes scrambled or unscrambled, and the encrypt object changes state (encryptors become decryptors, and decryptors be encryptors). Using different keys before calling this function gives different scrambling patterns The decryptor state differs from the encryptor state in that a decryptor cannot be moved, and cannot be changed to an encryptor. The scrambling can be removed by calling LAnnContainer::EncryptApply on the decryptor with the appropriate arguments. If successful, the decryptor again changes state to become an encryptor. An encryptor can be moved, and can be changed to a decryptor.

The encrypt object is useful for encrypting portions of a bitmap. After encrypting, the scrambled bitmap cannot easily be unscrambled without the associated annotation file. The scrambling can be removed by using the associated annotation file, or by using automation mode to manually change the encrypt state from encryptor to a decryptor, position the object correctly, and setting the key appropriately.

LAnnContainer::EncryptApply calls LBitmap::Scramble internally to shuffle the pixels. For more information, refer to LBitmap::Scramble.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example takes a pointer to an LAnnEncrypt object that is an encryptor, and does the following:

  1. Verifies that it is an encryptor that is associated with a bitmap
  2. changes the key to 123
  3. Applies the encryptor so that it changes state to a decryptor
  4. Prompts the user to continuev
  5. Removes the scrambling by applying the decryptor
    L_INT LAnnContainer_EncryptApplyExample(LAnnContainer *pLContainer, LAnnEncrypt *pLEncrypt)  
    { 
       L_INT nRet; 
     
       L_UINT uObjectType;  
     
       ANNENCRYPTOPTIONS EncryptOptions;  
     
       uObjectType = pLContainer->GetType(); 
     
       if (uObjectType != ANNOBJECT_CONTAINER)  
       { 
          MessageBox(NULL, TEXT("This object is not an encryptor."), TEXT("Error"), MB_OK);  
          return FAILURE ;  
       } 
     
       memset(&EncryptOptions, 0, sizeof(ANNENCRYPTOPTIONS));  
     
       EncryptOptions.uStructSize = sizeof(ANNENCRYPTOPTIONS);  
     
       EncryptOptions.uFlags = ANNENCRYPT_ALL;  
     
       nRet = pLEncrypt->GetEncryptOptions(&EncryptOptions);  
       if(nRet != SUCCESS) 
          return nRet; 
      
       if (EncryptOptions.pEncryptBitmap == NULL)  
     
       { 
          MessageBox(NULL, TEXT("The encrypt object is not associated with a bitmap."), TEXT("Error"), MB_OK);  
          return FAILURE ;  
       } 
     
       if (EncryptOptions.bEncryptor == FALSE)  
       { 
          MessageBox(NULL, TEXT("This object is a decryptor."), TEXT("Error"), MB_OK);  
          return FAILURE ;  
       } 
     
       // Change the key to '123' 
     
       EncryptOptions.uKey = 123;  
     
       EncryptOptions.uFlags = ANNENCRYPT_KEY;  
     
       nRet = pLEncrypt->SetEncryptOptions(&EncryptOptions, 0);  
       if(nRet != SUCCESS) 
          return nRet; 
     
       // Apply the encryptor 
     
       nRet = pLContainer->EncryptApply(ANNENCRYPTAPPLY_ENCRYPTOR, 0);  
       if(nRet != SUCCESS) 
          return nRet; 
     
       nRet = MessageBox(NULL, TEXT("Encryptor has been applied. Would you like to remove the encryption?"), TEXT(""), MB_YESNO);  
       if (nRet == IDYES)  
       { 
          pLContainer->EncryptApply(ANNENCRYPTAPPLY_DECRYPTOR, 0);  
       } 
     
       return SUCCESS; 
    } 
Help Version 20.0.2020.4.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help