System.IO.Stream object storing the image data.
The initial name of the file stored in the Stream object. IE: myfile.tif. The document format will be automatically detected based on this file name.
Example





In This Topic
GdPicture14 Namespace / GdPictureImaging Class / CreateGdPictureImageFromStream Method / CreateGdPictureImageFromStream(Stream,String) Method

CreateGdPictureImageFromStream(Stream,String) Method

In This Topic
Creates a new GdPicture image from an image stored into a Stream Object. This method uses a GdPicture DocumentFormat enumerator.
Syntax
'Declaration
 
Public Overloads Function CreateGdPictureImageFromStream( _
   ByVal Stream As Stream, _
   ByVal FileName As String _
) As Integer
public int CreateGdPictureImageFromStream( 
   Stream Stream,
   string FileName
)
public function CreateGdPictureImageFromStream( 
    Stream: Stream;
    FileName: String
): Integer; 
public function CreateGdPictureImageFromStream( 
   Stream : Stream,
   FileName : String
) : int;
public: int CreateGdPictureImageFromStream( 
   Stream* Stream,
   string* FileName
) 
public:
int CreateGdPictureImageFromStream( 
   Stream^ Stream,
   String^ FileName
) 

Parameters

Stream
System.IO.Stream object storing the image data.
FileName
The initial name of the file stored in the Stream object. IE: myfile.tif. The document format will be automatically detected based on this file name.

Return Value

0: The image could not be created. Use the GetStat() method to determine the reason this method failed. Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Remarks

The provided stream must support seeking.

Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.

Notes for multipage images (TIFF and GIF): By default, the class loads multipage images (GIF and TIFF) in read & write mode. To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images. If the image is a multipage file (TIFF, JBIG2, GIFF), the stream should be kept open until the image is released.

Example
Creating images using streams.
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);
    }
}
Applying ICM correction when saving CMYK based image as a tiff image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    string filePath = "image.jpg";
    if (gdpictureImaging.IsCMYKFile(filePath))
    {
        // Enable color correction.
        gdpictureImaging.EnableICM(true);
 
        using (System.IO.Stream inputStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open))
        {
            int imageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, filePath);
            using (System.IO.Stream outputStream = new System.IO.FileStream("output.tiff", System.IO.FileMode.CreateNew))
            {
                gdpictureImaging.SaveAsTIFF(imageID, outputStream, true, TiffCompression.TiffCompressionJPEG, 90);
            }
            // Release used resources.
            gdpictureImaging.ReleaseGdPictureImage(imageID);
        }
    }
}
See Also