Saves an 
Image to a stream in any of the supported compressed or uncompressed formats.
             
             
             
            
Syntax
            Parameters
- stream
 
- A Stream where the image data will be saved.
 - format
 
- The output file format. For valid values, refer to
            Summary of All Supported Image File Formats.
 - bitsPerPixel
 
- Resulting file's pixel depth. Note that not all bits per pixel are
            available to all file formats.  For valid values, refer to 
            Summary of All Supported Image File Formats. If
            bitsPerPixel is 0, the image will be stored using the closest bits per pixel value supported by that format.
            For example, if a file format supports 1, 4, and 24-bits per pixel, and
            RasterImage.BitsPerPixel is 5, the file will be stored as 24-bit. Likewise, if
            RasterImage.BitsPerPixel is 2, the file will be stored as 4-bit.
 - qualityFactor
 
- A quality factor to be used when saving the RasterImageViewerElement.Image to a stream.
 
 
             
              
             
             
            
Example
This example will load a 24 bits per pixel CMP image and save it to a stream.
 
             | Visual Basic |  Copy Code | 
|---|
Public Sub RasterImageViewerElement_Save1(ByVal viewer As RasterImageViewerElement) 
    Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp" 
    Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_SaveStream3.bin" 
 
     
    viewer.Load(srcFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1) 
 
     
    Dim ms As MemoryStream = New MemoryStream() 
 
     
    Console.WriteLine("Saving the image") 
    Dim position As Long = viewer.Save(ms, 0, RasterImageFormat.Cmp, 24, 100) 
 
    Console.WriteLine("{0} bytes saved to the stream") 
 
     
     
     
    Dim fs As FileStream = File.Create(destFileName) 
    Try 
        ms.WriteTo(fs) 
    Finally 
        CType(fs, IDisposable).Dispose() 
    End Try 
 
    ms.Close() 
 
     
 
     
    Console.WriteLine("Loading the file back") 
    viewer.Load(destFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1) 
End Sub | 
 
| C# |  Copy Code | 
|---|
public void RasterImageViewerElement_Save1(RasterImageViewerElement viewer)  {     string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp";     string destFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_SaveStream3.bin";       // Load the source image     viewer.Load(srcFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1);       // Create a memory stream     MemoryStream ms = new MemoryStream();       // Save this image to the stream after the header     Console.WriteLine("Saving the image");     long position = viewer.Save(ms, 0, RasterImageFormat.Cmp, 24, 100);       Console.WriteLine("{0} bytes saved to the stream");       // Save the stream to a file     using (FileStream fs = File.Create(destFileName))        ms.WriteTo(fs);       ms.Close();       // Make sure the saved file works       // Save the image to disk     Console.WriteLine("Loading the file back");     viewer.Load(destFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1);  } | 
 
  
            
            Remarks
            
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
 
            
            
See Also