GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / SaveAsStream Method
GdPicture image identifier.
The stream object to save the image.
A member of the DocumentFormat enumeration. Currently supported formats are:

DocumentFormatBMP.

DocumentFormatJPEG.

DocumentFormatPNG.

DocumentFormatTIFF.

DocumentFormatGIF.

DocumentFormatJ2K (JPEG2000 codestream).

DocumentFormatJP2 (JPEG2000)

DocumentFormatTARGA.

DocumentFormatEXR.

DocumentFormatWBMP.

DocumentFormatXPM.

DocumentFormatPBM.

DocumentFormatWMF.

DocumentFormatWEBP.

Compression or encoding quality to use.

For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).

For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).

For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.

For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.

For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.

For other formats use 0.

Example





In This Topic
SaveAsStream Method (GdPictureImaging)
In This Topic
Saves a GdPicture image to a stream. This methods can generate multipage tiff file if the input GdPicture image is an editable multipage tiff.
Syntax
'Declaration
 
Public Function SaveAsStream( _
   ByVal ImageID As Integer, _
   ByVal Stream As Stream, _
   ByVal ImageFormat As DocumentFormat, _
   ByVal EncoderParameter As Integer _
) As GdPictureStatus
public GdPictureStatus SaveAsStream( 
   int ImageID,
   Stream Stream,
   DocumentFormat ImageFormat,
   int EncoderParameter
)
public function SaveAsStream( 
    ImageID: Integer;
    Stream: Stream;
    ImageFormat: DocumentFormat;
    EncoderParameter: Integer
): GdPictureStatus; 
public function SaveAsStream( 
   ImageID : int,
   Stream : Stream,
   ImageFormat : DocumentFormat,
   EncoderParameter : int
) : GdPictureStatus;
public: GdPictureStatus SaveAsStream( 
   int ImageID,
   Stream* Stream,
   DocumentFormat ImageFormat,
   int EncoderParameter
) 
public:
GdPictureStatus SaveAsStream( 
   int ImageID,
   Stream^ Stream,
   DocumentFormat ImageFormat,
   int EncoderParameter
) 

Parameters

ImageID
GdPicture image identifier.
Stream
The stream object to save the image.
ImageFormat
A member of the DocumentFormat enumeration. Currently supported formats are:

DocumentFormatBMP.

DocumentFormatJPEG.

DocumentFormatPNG.

DocumentFormatTIFF.

DocumentFormatGIF.

DocumentFormatJ2K (JPEG2000 codestream).

DocumentFormatJP2 (JPEG2000)

DocumentFormatTARGA.

DocumentFormatEXR.

DocumentFormatWBMP.

DocumentFormatXPM.

DocumentFormatPBM.

DocumentFormatWMF.

DocumentFormatWEBP.

EncoderParameter
Compression or encoding quality to use.

For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).

For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).

For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.

For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.

For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.

For other formats use 0.

Return Value

A member of the GdPictureStatus enumeration.
Remarks

This method requires the Image Documents component to run.

Example
Cloning an area of a jpeg image into a new jpeg image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
    {
        int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, "image.jpg");
        //Clone an area of the source image into a mew image.
        int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
        //Process the cloned image.
        gdpictureImaging.FxPixelize(imageID2);
        using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
        {
            //Save a result into a new image file.
            gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
        }
        gdpictureImaging.ReleaseGdPictureImage(imageID2);
        gdpictureImaging.ReleaseGdPictureImage(imageID1);
    }
}
See Also