VintaSoft Imaging .NET SDK 15.1: Документация для .NET разработчика
Vintasoft.Imaging.Annotation Namespace / AnnotationData Class / GetBoundingBox Methods / GetBoundingBox() Method
Синтаксис Example Требования Смотрите также
В этом разделе
GetBoundingBox() Метод (AnnotationData)
В этом разделе
Возвращает ограничивающую рамку аннотации.
Синтаксис
'Declaration

Public Overloads Overridable Function GetBoundingBox() As System.Drawing.RectangleF

public virtual System.Drawing.RectangleF GetBoundingBox()

Return Value

Ограничительный прямоугольник аннотации.
Пример

Вот пример, показывающий, как проверить, находится ли аннотация внутри границ изображения:


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

Требования

Целевые платформы: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

Смотрите также