CreateClonedGdPictureImageArea Method (GdPictureImaging)
Creates a new GdPicture image from the defined area of the specified GdPicture image, that is represented by its unique image identifier. The newly created image is identified by its unique non-zero image identifier and it is independent of the defined source image.
Please note that it is your responsibility to release the image resources once you have no use for them.
public int CreateClonedGdPictureImageArea(
int ,
int ,
int ,
int ,
int
)
public function CreateClonedGdPictureImageArea(
: Integer;
: Integer;
: Integer;
: Integer;
: Integer
): Integer;
public function CreateClonedGdPictureImageArea(
: int,
: int,
: int,
: int,
: int
) : int;
public: int CreateClonedGdPictureImageArea(
int ,
int ,
int ,
int ,
int
)
public:
int CreateClonedGdPictureImageArea(
int ,
int ,
int ,
int ,
int
)
'Declaration
Public Function CreateClonedGdPictureImageArea( _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer _
) As Integer
Parameters
- ImageID
- A unique image identifier of the GdPicture image representing the source image, from which the specified area will be cloned.
- SrcLeft
- The horizontal (X) coordinate of the top left position of the required area to clone, in pixels.
- SrcTop
- The vertical (Y) coordinate of the top left position of the required area to clone, in pixels.
- Width
- The width of the required area to clone, in pixels.
- Height
- The height of the required area to clone, in pixels.
Return Value
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created. Please first of all use the
GdPictureImaging.GetStat method to determine if this method has been successful.
Be aware that you need to release the image with the GdPictureImaging.ReleaseGdPictureImage method after being used.
Cloning an area of a jpeg image into a new jpeg image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, "image.jpg");
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}