GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / SaveAsPNG Method / SaveAsPNG(Int32,String,Int32,Boolean) 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.

The level of compression to use, in the range 0 (no compression) to 9 (max compression). Suggested value is 6, using higer value should result in a smaller file size but also increases encoding time.
Specifies if the encoder must produce and interlaced version of the image. Interlacing increases file size.
Example





In This Topic
SaveAsPNG(Int32,String,Int32,Boolean) Method
In This Topic
Saves a GdPicture image as Portable Network Graphics image. This overload supports interlacing and compression level customization.
Syntax
'Declaration
 
Public Overloads Function SaveAsPNG( _
   ByVal ImageID As Integer, _
   ByVal FilePath As String, _
   ByVal CompressionLevel As Integer, _
   ByVal Interlaced As Boolean _
) As GdPictureStatus
public GdPictureStatus SaveAsPNG( 
   int ImageID,
   string FilePath,
   int CompressionLevel,
   bool Interlaced
)
public function SaveAsPNG( 
    ImageID: Integer;
    FilePath: String;
    CompressionLevel: Integer;
    Interlaced: Boolean
): GdPictureStatus; 
public function SaveAsPNG( 
   ImageID : int,
   FilePath : String,
   CompressionLevel : int,
   Interlaced : boolean
) : GdPictureStatus;
public: GdPictureStatus SaveAsPNG( 
   int ImageID,
   string* FilePath,
   int CompressionLevel,
   bool Interlaced
) 
public:
GdPictureStatus SaveAsPNG( 
   int ImageID,
   String^ FilePath,
   int CompressionLevel,
   bool Interlaced
) 

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.

CompressionLevel
The level of compression to use, in the range 0 (no compression) to 9 (max compression). Suggested value is 6, using higer value should result in a smaller file size but also increases encoding time.
Interlaced
Specifies if the encoder must produce and interlaced version of the image. Interlacing increases file size.

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
Drawing the red text "GdPicture.Net" on a png image and saving the image using maximum compression.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
 
    // Draw the text in the top left corner of the image.
    gdpictureImaging.DrawText(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true);
 
    // Save the output png using maximum compression.
    gdpictureImaging.SaveAsPNG(imageID, "output.png", 6, false);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also