VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Annotation Namespace / AnnotationData Class / GetBoundingBox Methods / GetBoundingBox() Method
Syntax Example Requirements SeeAlso
In This Topic
    GetBoundingBox() Method (AnnotationData)
    In This Topic
    Returns a bounding box of annotation.
    Syntax
    'Declaration
    
    Public Overloads Overridable Function GetBoundingBox() As System.Drawing.RectangleF
    
    
    public virtual System.Drawing.RectangleF GetBoundingBox()
    
    
    public: virtual System.Drawing.RectangleF* GetBoundingBox()
    
    
    public:
    virtual System.Drawing.RectangleF^ GetBoundingBox()

    Return Value

    Bounding box of annotation.
    Example

    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);
    }
    
    

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also