VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000 Namespace / Jpeg2000Page Class / Resolution Property
Syntax Example Requirements SeeAlso
In This Topic
Resolution Property (Jpeg2000Page)
In This Topic
Gets or sets the resolution, in pixels per inch, of this image page.
Syntax
'Declaration

Public Overrides Property Resolution As Vintasoft.Imaging.Resolution

public override Vintasoft.Imaging.Resolution Resolution { get; set; }

Property Value

The resolution loaded from an image metadata if HasResolution returns true; otherwise, the default (screen) resolution.
Example

This C#/VB.NET code shows how to change the resolution of JPEG2000 page.


' Changes resolution of Jpeg2000 page, saves Jpeg2000 file,
' checks that resolution has been changed correctly.
Public Shared Sub ChangeJpeg2000PageResolution(jpeg2000Filename As String, newResolution As Vintasoft.Imaging.Resolution)
    ' open an existing JPEG2000 file
    Using file As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite)
        Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page = file.Page

        page.Resolution = newResolution

        file.SaveChanges()
    End Using

    ' check that resolution is saved correctly

    Using file As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
        Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page = file.Page

        Dim resolution As Vintasoft.Imaging.Resolution = page.Resolution

        ' little difference is allowed
        If System.Math.Abs(resolution.Horizontal - newResolution.Horizontal) > 0.01 OrElse System.Math.Abs(resolution.Vertical - newResolution.Vertical) > 0.01 Then
            Throw New System.ApplicationException()
        End If
    End Using
End Sub


// Changes resolution of Jpeg2000 page, saves Jpeg2000 file,
// checks that resolution has been changed correctly.
public static void ChangeJpeg2000PageResolution(string jpeg2000Filename,
    Vintasoft.Imaging.Resolution newResolution)
{
    // open an existing JPEG2000 file
    using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File file =
        new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(
            jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
    {
        Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page page = file.Page;

        page.Resolution = newResolution;

        file.SaveChanges();
    }

    // check that resolution is saved correctly

    using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File file =
        new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000File(
            jpeg2000Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
    {
        Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000Page page = file.Page;

        Vintasoft.Imaging.Resolution resolution = page.Resolution;

        // little difference is allowed
        if (System.Math.Abs(resolution.Horizontal - newResolution.Horizontal) > 0.01 ||
            System.Math.Abs(resolution.Vertical - newResolution.Vertical) > 0.01)
        {
            throw new System.ApplicationException();
        }
    }
}

Requirements

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

See Also