SaveAsPNG(Int32,String) Method
Saves a GdPicture image as Portable Network Graphics image.
'Declaration
Public Overloads Function SaveAsPNG( _
ByVal As Integer, _
ByVal As String _
) As GdPictureStatus
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 GdPictureImaging.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.
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);
}