LEADTOOLS Annotations (Leadtools.Annotations assembly)

AnnEncryptObject Class

Show in webframe
Example 





Members 
Defines an annotation encrypt object.
Object Model
Syntax
Remarks

The encrypt annotation object is a rectangular object that is used to encrypt rectangular portions of an image.

It can also be used to encrypt the entire image. In design mode, the encrypt object is visible but partially transparent to show the part of the image that it covers. In run mode, the encrypt object is invisible.

You must call Apply(RasterImageViewer) to apply the encrypt object. Once applied, the portion of the image under the encrypt object becomes scrambled, and the encrypt object state changes to decryptor. Using different keys before calling this method 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 Apply(RasterImageViewer) on the decrypt object with the appropriate arguments. If successful, the decryptor state changes to encryptor. An encrypt object in the encryptor state can be moved, can have its Key changed, and can be changed to a decrypt object.

The encrypt object is useful for encrypting portions of an image. 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 state from encryptor to a decryptor, position it correctly, and setting the Key appropriately.

Overlapping regions can be encrypted. When encrypting overlapping regions, note the following points:

You cannot rotate an encrypt object, but you can flip or reverse it. If you rotate a container that includes an encrypt object, the encrypt object will move to the new position, but will retain its orientation.

This class implements the IAnnPrimarySecondaryPictureObject interface to handle primary and secondary pictures.

For more information, refer to Using Primary and Secondary Pictures in Annotation Objects.

If you are interested in locking an object, refer to Implementing Annotation Security.

For more information about the encrypt annotation object refer to the AnnEncryptObject. For more information about the automated encrypt annotation object, refer to Annotation Objects - Automated Features, Automated Annotations - Encrypt Tab. and Automated Annotations - Encrypt Pictures Tab.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.Codecs
Imports Leadtools.WinForms

Private Sub AnnEncryptObject_AnnEncryptObject(ByVal viewer As RasterImageViewer, ByVal container As AnnContainer)
   Dim encryptor As AnnEncryptObject = New AnnEncryptObject()
   encryptor.Bounds = New AnnRectangle(100, 100, 300, 300, AnnUnit.Pixel)
   encryptor.Key = 123
   encryptor.Encryptor = True
   container.Objects.Add(encryptor)
   viewer.Invalidate(encryptor.InvalidRectangle)
   MessageBox.Show(String.Format("Added encryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", encryptor.Encryptor, encryptor.IsEncrypted, encryptor.CanEncrypt, encryptor.CanDecrypt, container.Objects.Count))

   ' apply (encryptor)
   encryptor.Apply(viewer)
   viewer.Invalidate(encryptor.InvalidRectangle)
   MessageBox.Show(String.Format("Applied encryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", encryptor.Encryptor, encryptor.IsEncrypted, encryptor.CanEncrypt, encryptor.CanDecrypt, container.Objects.Count))

   ' remove from the container
   container.Objects.Remove(encryptor)
   viewer.Invalidate()
   MessageBox.Show(String.Format("Removed encryptor. Objects in container: {0}", container.Objects.Count))

   ' create another encrypt object to decrypt the first object
   Dim decryptor As AnnEncryptObject = New AnnEncryptObject()
   decryptor.Bounds = New AnnRectangle(100, 100, 300, 300, AnnUnit.Pixel)
   decryptor.Key = 123
   decryptor.Encryptor = False
   container.Objects.Add(decryptor)
   viewer.Invalidate(decryptor.InvalidRectangle)
   MessageBox.Show(String.Format("Added decryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", decryptor.Encryptor, decryptor.IsEncrypted, decryptor.CanEncrypt, decryptor.CanDecrypt, container.Objects.Count))

   ' apply (decryptor)
   decryptor.Apply(viewer)
   viewer.Invalidate(decryptor.InvalidRectangle)
   MessageBox.Show(String.Format("Applied decryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", decryptor.Encryptor, decryptor.IsEncrypted, decryptor.CanEncrypt, decryptor.CanDecrypt, container.Objects.Count))

   ' remove from the container
   container.Objects.Remove(decryptor)
   viewer.Invalidate()
   MessageBox.Show(String.Format("Removed decryptor. Objects in container: {0}", container.Objects.Count))
End Sub
using Leadtools;
using Leadtools.Annotations;
using Leadtools.Codecs;
using Leadtools.WinForms;

private void AnnEncryptObject_AnnEncryptObject(RasterImageViewer viewer, AnnContainer container)
{
   AnnEncryptObject encryptor = new AnnEncryptObject();
   encryptor.Bounds = new AnnRectangle(100, 100, 300, 300, AnnUnit.Pixel);
   encryptor.Key = 123;
   encryptor.Encryptor = true;
   container.Objects.Add(encryptor);
   viewer.Invalidate(encryptor.InvalidRectangle);
   MessageBox.Show(String.Format("Added encryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", encryptor.Encryptor, encryptor.IsEncrypted, encryptor.CanEncrypt, encryptor.CanDecrypt, container.Objects.Count));

   // apply (encryptor)
   encryptor.Apply(viewer);
   viewer.Invalidate(encryptor.InvalidRectangle);
   MessageBox.Show(String.Format("Applied encryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", encryptor.Encryptor, encryptor.IsEncrypted, encryptor.CanEncrypt, encryptor.CanDecrypt, container.Objects.Count));

   // remove from the container
   container.Objects.Remove(encryptor);
   viewer.Invalidate();
   MessageBox.Show(String.Format("Removed encryptor. Objects in container: {0}", container.Objects.Count));

   // create another encrypt object to decrypt the first object
   AnnEncryptObject decryptor = new AnnEncryptObject();
   decryptor.Bounds = new AnnRectangle(100, 100, 300, 300, AnnUnit.Pixel);
   decryptor.Key = 123;
   decryptor.Encryptor = false;
   container.Objects.Add(decryptor);
   viewer.Invalidate(decryptor.InvalidRectangle);
   MessageBox.Show(String.Format("Added decryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", decryptor.Encryptor, decryptor.IsEncrypted, decryptor.CanEncrypt, decryptor.CanDecrypt, container.Objects.Count));

   // apply (decryptor)
   decryptor.Apply(viewer);
   viewer.Invalidate(decryptor.InvalidRectangle);
   MessageBox.Show(String.Format("Applied decryptor. Encryptor: {0}, IsEncrypted: {1}, CanEncrypt: {2}, CanDecrypt: {3}, Objects in container: {4}", decryptor.Encryptor, decryptor.IsEncrypted, decryptor.CanEncrypt, decryptor.CanDecrypt, container.Objects.Count));

   // remove from the container
   container.Objects.Remove(decryptor);
   viewer.Invalidate();
   MessageBox.Show(String.Format("Removed decryptor. Objects in container: {0}", container.Objects.Count));
}
Requirements

Target Platforms

See Also

Reference

AnnEncryptObject Members
Leadtools.Annotations Namespace

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.