The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the copied region's rectangle, related to the current page.
The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the copied region's rectangle, related to the current page.
The width, in pixels, of the region's rectangle.
The height, in pixels, of the region's rectangle.
Example





In This Topic
GdPicture14 Namespace / GdViewer Class / CopyRegionToGdPictureImage Method

CopyRegionToGdPictureImage Method (GdViewer)

In This Topic
Copies the content of the specified region, related to the current page of the document displayed in the GdViewer control, into a GdPictureImage object. Please ensure, that specified coordinates and dimensions correspond to the actual document pages area of the currently displayed page.

The method creates a new GdPictureImage object of the required area on the displayed page. The resulting image is recognizable by its unique image identifier. Please note that you have to release the created image from the memory using the ReleaseGdPictureImage method.

Syntax
'Declaration

 

Public Function CopyRegionToGdPictureImage( _

   ByVal SrcLeft As Integer, _

   ByVal SrcTop As Integer, _

   ByVal Width As Integer, _

   ByVal Height As Integer _

) As Integer
public int CopyRegionToGdPictureImage( 

   int SrcLeft,

   int SrcTop,

   int Width,

   int Height

)
public function CopyRegionToGdPictureImage( 

    SrcLeft: Integer;

    SrcTop: Integer;

    Width: Integer;

    Height: Integer

): Integer; 
public function CopyRegionToGdPictureImage( 

   SrcLeft : int,

   SrcTop : int,

   Width : int,

   Height : int

) : int;
public: int CopyRegionToGdPictureImage( 

   int SrcLeft,

   int SrcTop,

   int Width,

   int Height

) 
public:

int CopyRegionToGdPictureImage( 

   int SrcLeft,

   int SrcTop,

   int Width,

   int Height

) 

Parameters

SrcLeft
The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the copied region's rectangle, related to the current page.
SrcTop
The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the copied region's rectangle, related to the current page.
Width
The width, in pixels, of the region's rectangle.
Height
The height, in pixels, of the region's rectangle.

Return Value

A unique image identifier of the newly created image referring to an associated GdPictureImage object. The GetStat method can be subsequently used to determine if this method has been successful.

Just to remind you that you need to release the image from the memory using the ReleaseGdPictureImage method after being used.

Remarks
It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

This method expects to have a core GdPicture license to be unlocked.

Example
How to create an image from the content of the visible area of the current page.
'We assume that the GdViewer1 control has been properly integrated.

If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then

    Dim left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0

    GdViewer1.GetDisplayedArea(left, top, width, height)

    Dim imageID As Integer = GdViewer1.CopyRegionToGdPictureImage(left, top, width, height)

    If GdViewer1.GetStat() = GdPictureStatus.OK Then

        Using oImage As GdPictureImaging = New GdPictureImaging()

            If oImage.SaveAsJPEG(imageID, "visible_region.jpg") = GdPictureStatus.OK Then

                MessageBox.Show("Done!", "GdViewer.CopyRegionToGdPictureImage")

            Else

                MessageBox.Show("The image can't be saved. Status: " + oImage.GetStat().ToString(), "GdViewer.CopyRegionToGdPictureImage")

            End If

        End Using

        GdViewer1.ReleaseGdPictureImage(imageID)

    Else

        MessageBox.Show("The image can't be created. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CopyRegionToGdPictureImage")

    End If

Else

    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CopyRegionToGdPictureImage")

End If
//We assume that the GdViewer1 control has been properly integrated.

if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)

{

    int left = 0, top = 0, width = 0, height = 0;

    GdViewer1.GetDisplayedArea(ref left, ref top, ref width, ref height);

    int imageID = GdViewer1.CopyRegionToGdPictureImage(left, top, width, height);

    if (GdViewer1.GetStat() == GdPictureStatus.OK)

    {

        using (GdPictureImaging oImage = new GdPictureImaging())

        {

            if (oImage.SaveAsJPEG(imageID, "visible_region.jpg") == GdPictureStatus.OK)

                MessageBox.Show("Done!", "GdViewer.CopyRegionToGdPictureImage");

            else

                MessageBox.Show("The image can't be saved. Status: " + oImage.GetStat().ToString(), "GdViewer.CopyRegionToGdPictureImage");

        }

        GdViewer1.ReleaseGdPictureImage(imageID);

    }

    else MessageBox.Show("The image can't be created. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CopyRegionToGdPictureImage");

}

else

    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.CopyRegionToGdPictureImage");
See Also