GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / CreateClonedGdPictureImage Method
A unique image identifier of the GdPicture image representing the source image to clone.
Example





In This Topic
CreateClonedGdPictureImage Method (GdPictureImaging)
In This Topic
Creates a new GdPicture image and initializes it with a copy of the content 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.

Syntax
'Declaration
 
Public Function CreateClonedGdPictureImage( _
   ByVal ImageID As Integer _
) As Integer
public int CreateClonedGdPictureImage( 
   int ImageID
)
public function CreateClonedGdPictureImage( 
    ImageID: Integer
): Integer; 
public function CreateClonedGdPictureImage( 
   ImageID : int
) : int;
public: int CreateClonedGdPictureImage( 
   int ImageID
) 
public:
int CreateClonedGdPictureImage( 
   int ImageID
) 

Parameters

ImageID
A unique image identifier of the GdPicture image representing the source image to clone.

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 GetStat method to determine if this method has been successful.

Be aware that you need to release the image with 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.

Be aware, that if the source image is a multi-bitmap image, this method will clone only the currently selected bitmap (the current page) and it will create a single frame image.

Example
Cloning an existing GdPicture image to a new one.
Applying the fire effect and negative effect to two duplicates of the same image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // Create two duplicate gdpicture images from the input file.
    int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
    int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
 
    // Process both of your images (differently).
    gdpictureImaging.FxFire(imageID1);
    gdpictureImaging.FxNegative(imageID2);
 
    // Save your images in the same multipage tif file.
    gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
    gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
    gdpictureImaging.TiffCloseMultiPageFile(imageID1);
    gdpictureImaging.ReleaseGdPictureImage(imageID1);
    gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Saving the pages of a dicom document to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
 
    // Create a tiff with the first page.
    int tiffImageID = gdpictureImaging.CreateClonedGdPictureImage(dcmImageID);
    gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
 
    // Add the remaining pages as additional pages to the tif.
    int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
    for (int pageNo = 2; pageNo <= pageCount; pageNo++)
    {
        gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
        gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, dcmImageID, TiffCompression.TiffCompressionAUTO);
    }
 
    gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
 
    gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
    gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
See Also