Using Pictures in Annotation Objects (original) (raw)
The AnnPicture class provides a picture object that is used by several LEADTOOLS annotation object classes. The following LEADTOOLS annotation objects use the AnnPicture class:
Each of these classes (either through the direct implementation or inheritance) access properties that control how the AnnPicture is used in the annotation object.
AnnImageObject:
The AnnImageObject class derives from AnnRectangleObject and adds the Picture property to fill the object's Bounds.
AnnHotspotObject:
The AnnHotspotObject class derives from AnnImageObject and adds the DefaultPicture property to set the default AnnPicture used to fill the object's Bounds.
AnnFreehandHotspotObject:
The AnnFreehandHotspotObject class derives from AnnPolylineObject and adds both the Picture and DefaultPicture properties.
AnnPointObject:
The AnnPointObject class derives from AnnObject and adds both the Picture and DefaultPicture properties.
**AnnStampObject:**The AnnStampObject class derives from AnnTextObject and adds the Picture property.
AnnPicture from External PNG File or Data
The following examples will create an AnnStampObject with a picture stored in an external PNG file or data:
- Using a .NET
System.Drawing.Image
object:
C#// This example will create a new stamp object at the specified bounds and with the picture data from the specified PNG
// and add it to the container
void CreateStampFromPngFile(AnnContainer container, LeadRectD bounds, Image pngImage)
{
// Create a new AnnStampObject
AnnStampObject stampObject = new AnnStampObject();
// Set its bounds
stampObject.Rect = bounds;
// Set the picture from the PNG
AnnPicture picture = new AnnPicture(pngImage);
stampObject.Picture = picture;
// Add the stamp object to the container
container.Children.Add(stampObject);
}
- Using PNG data stored in a byte array:
C#// This example will create a new stamp object at the specified bounds and with the picture data from the specified PNG
// and add it to the container
void CreateStampFromPngFile(AnnContainer container, LeadRectD bounds, byte[] pngImage)
{
// Create a new AnnStampObject
AnnStampObject stampObject = new AnnStampObject();
// Set its bounds
stampObject.Rect = bounds;
// Set the picture from the PNG
AnnPicture picture = new AnnPicture(pngImage);
stampObject.Picture = picture;
// Add the stamp object to the container
container.Children.Add(stampObject);
}