VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Annotation Namespace / AnnotationData Class / GetBoundingBox Method / GetBoundingBox() Method

In This Topic
    GetBoundingBox() Method
    In This Topic
    Returns a bounding box of annotation.
    Public Overloads Overridable Function GetBoundingBox() As RectangleF
    public virtual RectangleF GetBoundingBox()
    public: virtual RectangleF GetBoundingBox(); 
    virtual RectangleF GetBoundingBox(); 

    Return Value

    Bounding box of annotation.
    This example shows how to check if the annotation is 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: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also