GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureImaging Class / CreateGdPictureImageFromFile Method / CreateGdPictureImageFromFile(String,Boolean) 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 GdPictureImaging.GetLastPath method to retrieve the path of the selected file.

Specifies if the document content will be loaded into memory (true). Loading the document content directly into memory results in a better manipulation performance, but it consumes more memory. If you load a file into memory, you can subsequently overwrite or delete the file.
Example





In This Topic
CreateGdPictureImageFromFile(String,Boolean) Method
In This Topic
Creates a new GdPicture image representing the image based on an input image file according to what you have specified. You can also specify if the file content is loaded into memory or not 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, _
   ByVal LoadInMemory As Boolean _
) As Integer
public int CreateGdPictureImageFromFile( 
   string FilePath,
   bool LoadInMemory
)
public function CreateGdPictureImageFromFile( 
    FilePath: String;
    LoadInMemory: Boolean
): Integer; 
public function CreateGdPictureImageFromFile( 
   FilePath : String,
   LoadInMemory : boolean
) : int;
public: int CreateGdPictureImageFromFile( 
   string* FilePath,
   bool LoadInMemory
) 
public:
int CreateGdPictureImageFromFile( 
   String^ FilePath,
   bool LoadInMemory
) 

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.

LoadInMemory
Specifies if the document content will be loaded into memory (true). Loading the document content directly into memory results in a better manipulation performance, but it consumes more memory. If you load a file into memory, you can subsequently overwrite or delete the 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.

Remarks
It is recommend to use the GdPictureImaging.GetStat method to identify the specific reason for the method's failure, if any.

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

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 GdPictureImaging.GifOpenMultiFrameForWrite method for GIF format and the GdPictureImaging.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())
{
    // LoadInMemory parameter is set to true in order to be able to update the input file.
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
    gdpictureImaging.FxNegative(imageID);
    gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removing the white margins from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // LoadInMemory parameter is set to true in order to be able to update the input file.
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
 
    // Detect and remove the white margins using the default confidence level.
    gdpictureImaging.CropWhiteBorders(imageID);
 
    gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also