L_AnnEncryptApply
#include "l_bitmap.h"
L_LTANN_API L_INT L_AnnEncryptApply(hObject, uEncryptFlags, uFlags)
HANNOBJECT hObject; |
/* handle to the annotation object */ |
L_UINT uEncryptFlags; |
/* flags that determine which objects to apply */ |
L_UINT uFlags; |
/* flags that determine which objects to process */ |
Applies an encryptor annotation object to the underlying bitmap.
Parameter |
Description |
|
hObject |
Handle to the annotation object. |
|
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 |
|
ANNENCRYPTAPPLY_BOTH |
[0x003] Apply both encryptor and decryptor objects |
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 L_AnnGetSelected and L_AnnSetSelected 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
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 L_AnnEncryptApply 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.
L_AnnEncryptApply calls L_ScrambleBitmap internally to shuffle the pixels. For more information, refer to L_ScrambleBitmap.
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. |
Win32, x64.
See Also
Functions: |
L_AnnGetMetafile, L_AnnSetMetafile, L_AnnGetPredefinedMetafile, L_ScrambleBitmap, L_AnnGetEncryptOptions, L_AnnSetEncryptOptions, L_AnnGetPredefinedBitmap |
Topics: |
|
|
|
|
|
|
|
|
Example
This example takes a handle to an encrypt annotation 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 continue 5. Removes the scrambling by applying the decryptor
L_INT AnnEncryptApplyExample(HANNOBJECT hObject) { L_INT nRet; L_UINT uObjectType; ANNENCRYPTOPTIONS EncryptOptions; nRet = L_AnnGetType(hObject, &uObjectType); if(nRet != SUCCESS) return nRet; if (uObjectType != ANNOBJECT_ENCRYPT) { MessageBox(NULL, TEXT("This object is not an encryptor"), TEXT("Error"), MB_OK); return 0; } memset(&EncryptOptions, 0, sizeof(ANNENCRYPTOPTIONS)); EncryptOptions.uStructSize = sizeof(ANNENCRYPTOPTIONS); EncryptOptions.uFlags = ANNENCRYPT_ALL; nRet = L_AnnGetEncryptOptions(hObject, &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 0; } if (EncryptOptions.bEncryptor == FALSE) { MessageBox(NULL, TEXT("This object is a decryptor"), TEXT("Error"), MB_OK); return 0; } // Change the key to '123' EncryptOptions.uKey = 123; EncryptOptions.uFlags = ANNENCRYPT_KEY; nRet = L_AnnSetEncryptOptions(hObject, &EncryptOptions, 0); if(nRet != SUCCESS) return nRet; // Apply the encryptor nRet = L_AnnEncryptApply(hObject, 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) { nRet = L_AnnEncryptApply(hObject, ANNENCRYPTAPPLY_DECRYPTOR, 0); if(nRet != SUCCESS) return nRet; } return SUCCESS; }