Reference Guide
GdPicture14 Namespace / GdPictureImaging Class / CreateGdPictureImageFromFile Method / CreateGdPictureImageFromFile(String) Method
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 GetLastPath method to retrieve the path of the selected file.

Example





In This Topic
    CreateGdPictureImageFromFile(String) Method
    In This Topic
    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.

    Syntax
    'Declaration
     
    
    Public Overloads Function CreateGdPictureImageFromFile( _
       ByVal FilePath As String _
    ) As Integer
    public int CreateGdPictureImageFromFile( 
       string FilePath
    )
    public function CreateGdPictureImageFromFile( 
        FilePath: String
    ): Integer; 
    public function CreateGdPictureImageFromFile( 
       FilePath : String
    ) : int;
    public: int CreateGdPictureImageFromFile( 
       string* FilePath
    ) 
    public:
    int CreateGdPictureImageFromFile( 
       String^ FilePath
    ) 

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

    Be aware that you need to release the image resource with the ReleaseGdPictureImage method after being used.

    Remarks
    We strongly recommend using the GetStat method to identify the specific reason for the method's failure.

    All document formats currently supported by the toolkit are listed here.

    Please note that this class loads multipage images (GIF and TIFF formats) in read-write mode by default. If you want to open multipage images in read-only mode, you need to call the GifOpenMultiFrameForWrite method for GIF format and the TiffOpenMultiPageForWrite method for TIFF format and set the WriteAccess parameter to false before creating an image.

    Example
    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);
    }
    See Also