VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.ImageProcessing.Document Namespace / DocumentPerspectiveCorrectionCommand Class / DocumentAspectRatio Property
Синтаксис Example Требования Смотрите также
В этом разделе
    DocumentAspectRatio Свойство (DocumentPerspectiveCorrectionCommand)
    В этом разделе
    Возвращает или задает соотношение сторон изображения документа.
    Синтаксис
    'Declaration
    
    <DescriptionAttribute("The document image aspect ratio.")>
    <DefaultValueAttribute(0)>
    Public Property DocumentAspectRatio As Double
    
    
    [Description("The document image aspect ratio.")]
    [DefaultValue(0)]
    public double DocumentAspectRatio { get; set; }
    
    
    [Description("The document image aspect ratio.")]
    [DefaultValue(0)]
    public: __property double get_DocumentAspectRatio();
    public: __property void set_DocumentAspectRatio(
    double value
    );
    [Description("The document image aspect ratio.")]
    [DefaultValue(0)]
    public:
    property double DocumentAspectRatio { double get(); void set(double value); }

    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 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

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