VintaSoft Imaging .NET SDK 15.2: Документация для .NET разработчика
Vintasoft.Imaging.ImageProcessing.Document Namespace / DocumentPerspectiveCorrectionCommand Class / DocumentAspectRatio Property
Синтаксис Example Требования Смотрите также
В этом разделе
DocumentAspectRatio Свойство (DocumentPerspectiveCorrectionCommand)
В этом разделе
Возвращает или задает соотношение сторон изображения документа.
Синтаксис
'Declaration

<DefaultValueAttribute(0)>
<DescriptionAttribute("The document image aspect ratio.")>
Public Property DocumentAspectRatio As Double

[DefaultValue(0)]
[Description("The document image aspect ratio.")]
public double DocumentAspectRatio { get; set; }

Property Value

0 - соотношение сторон рассчитывается автоматически.
Значение по умолчанию - 0.
Пример

Вот C#/VB.NET код, который демонстрирует, как загрузить изображение с диска, исправить искажение перспективы в изображении документа A4 и сохранить результат в новый файл изображения.


''' <summary>
''' Corrects perspective distortion of A4 document image.
''' </summary>
''' <param name="sourceFile">Source file.</param>
''' <param name="resultFile">Result file.</param>
Public Sub ApplyPerspectiveCorrectionA4Paper(sourceFile As String, resultFile As String)
    Using image As New Vintasoft.Imaging.VintasoftImage(sourceFile)
        ' create the perspective correction command
        Dim command As New Vintasoft.Imaging.ImageProcessing.Document.DocumentPerspectiveCorrectionCommand()

        ' set the document aspect ratio to the aspect ratio of the A4 paper
        Dim paperSizeA4 As Vintasoft.Imaging.ImageSize = Vintasoft.Imaging.ImageSize.FromPaperKind(Vintasoft.Imaging.PaperSizeKind.A4)
        command.DocumentAspectRatio = paperSizeA4.WidthInDip / paperSizeA4.HeightInDip

        ' apply the perspective correction to a document image
        command.ExecuteInPlace(image)

        ' save the result image to a file
        image.Save(resultFile)
    End Using
End Sub


/// <summary>
/// Corrects perspective distortion of A4 document image.
/// </summary>
/// <param name="sourceFile">Source file.</param>
/// <param name="resultFile">Result file.</param>
public void ApplyPerspectiveCorrectionA4Paper(string sourceFile, string resultFile)
{
    using (Vintasoft.Imaging.VintasoftImage image =
        new Vintasoft.Imaging.VintasoftImage(sourceFile))
    {
        // create the perspective correction command
        Vintasoft.Imaging.ImageProcessing.Document.DocumentPerspectiveCorrectionCommand command =
            new Vintasoft.Imaging.ImageProcessing.Document.DocumentPerspectiveCorrectionCommand();

        // set the document aspect ratio to the aspect ratio of the A4 paper
        Vintasoft.Imaging.ImageSize paperSizeA4 = Vintasoft.Imaging.ImageSize.FromPaperKind(Vintasoft.Imaging.PaperSizeKind.A4);
        command.DocumentAspectRatio = paperSizeA4.WidthInDip / paperSizeA4.HeightInDip;

        // apply the perspective correction to a document image
        command.ExecuteInPlace(image);

        // save the result image to a file
        image.Save(resultFile);
    }
}

Требования

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

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