GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / SaveAsPNG Method / SaveAsPNG(Int32,String) Method
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file. If the specified file already exists, it will be overwritten.

You can subsequently use the GetLastPath method to retrieve the path of the selected file.

Example





In This Topic
SaveAsPNG(Int32,String) Method
In This Topic
Saves a GdPicture image as Portable Network Graphics image.
Syntax
'Declaration
 
Public Overloads Function SaveAsPNG( _
   ByVal ImageID As Integer, _
   ByVal FilePath As String _
) As GdPictureStatus
public GdPictureStatus SaveAsPNG( 
   int ImageID,
   string FilePath
)
public function SaveAsPNG( 
    ImageID: Integer;
    FilePath: String
): GdPictureStatus; 
public function SaveAsPNG( 
   ImageID : int,
   FilePath : String
) : GdPictureStatus;
public: GdPictureStatus SaveAsPNG( 
   int ImageID,
   string* FilePath
) 
public:
GdPictureStatus SaveAsPNG( 
   int ImageID,
   String^ FilePath
) 

Parameters

ImageID
A unique image identifier of the GdPicture image representing the image to be saved.
FilePath
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file. If the specified file already exists, it will be overwritten.

You can subsequently use the GetLastPath method to retrieve the path of the selected file.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks

This method requires the Image Documents component to run.

Example
Saving a processed GdPicture image as a png file.
Change image contrast using random value and saves result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
 
    // Change image contrast using random value. Allowed values are from -100 to +100.
    Random random = new Random();
    int contrast = random.Next(-100, 100);
    gdpictureImaging.SetContrast(imageID, contrast);
 
    gdpictureImaging.SaveAsPNG(imageID, "output.png");
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Cropping from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
 
    // Remove 5% all around the image.
    int height = gdpictureImaging.GetHeight(imageID);
    int width = gdpictureImaging.GetWidth(imageID);
    gdpictureImaging.Crop(imageID, width * 5 / 100, height * 5 / 100, width * 90 / 100, height * 90 / 100);
    
    gdpictureImaging.SaveAsPNG(imageID, "crop.png");
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also