GetBoundingBox() Method (AnnotationData)
Returns a bounding box of annotation.
Return Value
Bounding box of annotation.
Here is an example that shows how to check if the annotation is located inside the image boundaries:
Private Function IsAnnotationInsideImage(annotation As Vintasoft.Imaging.Annotation.AnnotationData, image As Vintasoft.Imaging.VintasoftImage) As Boolean
' get the bounding box
Dim boundingBox As System.Drawing.RectangleF = annotation.GetBoundingBox()
' calculate image size in device independent pixels
Dim imageWidthInDips As Single = image.Width * 96F / CSng(image.Resolution.Horizontal)
Dim imageHeightInDips As Single = image.Height * 96F / CSng(image.Resolution.Vertical)
Dim imageRect As New System.Drawing.RectangleF(0, 0, imageWidthInDips, imageHeightInDips)
' check if image rectangle contains the bounding box
Return imageRect.Contains(boundingBox)
End Function
bool IsAnnotationInsideImage(
Vintasoft.Imaging.Annotation.AnnotationData annotation,
Vintasoft.Imaging.VintasoftImage image)
{
// get the bounding box
System.Drawing.RectangleF boundingBox = annotation.GetBoundingBox();
// calculate image size in device independent pixels
float imageWidthInDips = image.Width * 96f / (float)image.Resolution.Horizontal;
float imageHeightInDips = image.Height * 96f / (float)image.Resolution.Vertical;
System.Drawing.RectangleF imageRect =
new System.Drawing.RectangleF(0, 0, imageWidthInDips, imageHeightInDips);
// check if image rectangle contains the bounding box
return imageRect.Contains(boundingBox);
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5