VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPage Class / PointsFromImageSpaceToPageSpace Method
Provides points, in the image's coordinate space, to convert; returns the converted points, in the PDF page's coordinate space.
Resolution of the image coordinate space.
Example



In This Topic
    PointsFromImageSpaceToPageSpace Method
    In This Topic
    Converts points from image coordinate space to PDF page coordinate space taking into account the image resolution, PDF page crop box, PDF page media box and PDF page rotation.
    Syntax
    'Declaration
     
    Public Sub PointsFromImageSpaceToPageSpace( _
       ByVal points() As PointF, _
       ByVal imageResolution As Resolution _
    ) 
    public void PointsFromImageSpaceToPageSpace( 
       PointF[] points,
       Resolution imageResolution
    )
    public: void PointsFromImageSpaceToPageSpace( 
       PointF[]* points,
       Resolution imageResolution
    ) 
    public:
    void PointsFromImageSpaceToPageSpace( 
       array<PointF>^ points,
       Resolution imageResolution
    ) 

    Parameters

    points
    Provides points, in the image's coordinate space, to convert; returns the converted points, in the PDF page's coordinate space.
    imageResolution
    Resolution of the image coordinate space.
    Example
    This example shows how to convert the rectangle coordinates from the image coordinate space to the PDF page coordinate space.
    ''' <summary>
    ''' Converts the rectangle from image space to page space.
    ''' </summary>
    ''' <param name="rect">Rectangle in image space.</param>
    ''' <param name="imageResolution">The image resolution.</param>
    ''' <param name="page">The PDF page.</param>
    ''' <returns><see cref="System.Drawing.RectangleF"/> structure in PDF page space.</returns>
    Public Shared Function ConvertRectangleFromImageSpaceToPageSpace(rect As System.Drawing.RectangleF, imageResolution As Vintasoft.Imaging.Resolution, page As Vintasoft.Imaging.Pdf.Tree.PdfPage) As System.Drawing.RectangleF
    	' Rectangle -> PointF[]
    	Dim points As System.Drawing.PointF() = New System.Drawing.PointF() {rect.Location, New System.Drawing.PointF(rect.X + rect.Width, rect.Y + rect.Height)}
                
    	' ImageSpace -> PageSpace
    	page.PointsFromImageSpaceToPageSpace(points, imageResolution)
                
    	' Points -> RectangleF
    	Dim x0 As Single = System.Math.Min(points(0).X, points(1).X)
    	Dim y0 As Single = System.Math.Min(points(0).Y, points(1).Y)
    	Dim x1 As Single = System.Math.Max(points(0).X, points(1).X)
    	Dim y1 As Single = System.Math.Max(points(0).Y, points(1).Y)
    	Return New System.Drawing.RectangleF(x0, y0, x1 - x0, y1 - y0)
    End Function
    /// <summary>
    /// Converts the rectangle from image space to page space.
    /// </summary>
    /// <param name="rect">Rectangle in image space.</param>
    /// <param name="imageResolution">The image resolution.</param>
    /// <param name="page">The PDF page.</param>
    /// <returns><see cref="System.Drawing.RectangleF"/> structure in PDF page space.</returns>
    public static System.Drawing.RectangleF ConvertRectangleFromImageSpaceToPageSpace(
        System.Drawing.RectangleF rect, 
        Vintasoft.Imaging.Resolution imageResolution, 
        Vintasoft.Imaging.Pdf.Tree.PdfPage page)
    {
        // Rectangle -> PointF[]
        System.Drawing.PointF[] points = new System.Drawing.PointF[] { 
            rect.Location, 
            new System.Drawing.PointF(rect.X + rect.Width, rect.Y + rect.Height) };
                
        // ImageSpace -> PageSpace
        page.PointsFromImageSpaceToPageSpace(points, imageResolution);
                
        // Points -> RectangleF
        float x0 = System.Math.Min(points[0].X, points[1].X);
        float y0 = System.Math.Min(points[0].Y, points[1].Y);
        float x1 = System.Math.Max(points[0].X, points[1].X);
        float y1 = System.Math.Max(points[0].Y, points[1].Y);
        return new System.Drawing.RectangleF(x0, y0, x1 - x0, y1 - y0);
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also