CopyRegionToGdPictureImage Method (GdViewer)
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 GdViewer.ReleaseGdPictureImage method.
public int CopyRegionToGdPictureImage(
int ,
int ,
int ,
int
)
public function CopyRegionToGdPictureImage(
: Integer;
: Integer;
: Integer;
: Integer
): Integer;
public function CopyRegionToGdPictureImage(
: int,
: int,
: int,
: int
) : int;
public: int CopyRegionToGdPictureImage(
int ,
int ,
int ,
int
)
public:
int CopyRegionToGdPictureImage(
int ,
int ,
int ,
int
)
'Declaration
Public Function CopyRegionToGdPictureImage( _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer _
) As Integer
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
GdViewer.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 GdViewer.ReleaseGdPictureImage method after being used.
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");