CreateGdPictureImageFromFile(String) Method
Creates a new GdPicture image representing the image based on an input image file. The file content is not loaded into memory using this method. The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
public int CreateGdPictureImageFromFile(
string
)
public function CreateGdPictureImageFromFile(
: String
): Integer;
public function CreateGdPictureImageFromFile(
: String
) : int;
public: int CreateGdPictureImageFromFile(
string*
)
public:
int CreateGdPictureImageFromFile(
String^
)
'Declaration
Public Overloads Function CreateGdPictureImageFromFile( _
ByVal As String _
) As Integer
Parameters
- FilePath
- The file path of the input image file. Use the empty string to allow the control to prompt users to select a file.
You can subsequently use the GdPictureImaging.GetLastPath method to retrieve the path of the selected file.
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 resource with the GdPictureImaging.ReleaseGdPictureImage method after being used.
Creating a GdPicture image from an image file.
Performing a negative effect on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saving the pages of a dicom document to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm");
// 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);
}