Saves a
Image to a stream in any of the supported compressed or uncompressed formats.
Overload List
Overload | Description |
Save(Stream,RasterImageFormat,Int32,Int32) |
Saves a Image to a stream in any of the supported compressed or uncompressed formats.
|
Save(String,RasterImageFormat,Int32,Int32) |
Saves a Image to a file in any of the supported compressed or uncompressed formats.
|
Save(Stream,Int64,RasterImageFormat,Int32,Int32) |
Saves a Image to a stream using an offset within it, in any of the supported compressed or uncompressed formats.
|
Example
This example will load a 24 bits per pixel CMP image and save it to a stream.
Visual Basic | Copy Code |
---|
Public Sub RasterImageViewer_Save1(ByVal viewer As RasterImageViewer)
Dim srcFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"
Dim destFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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 RasterImageViewer_Save1(RasterImageViewer viewer) { string srcFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"; string destFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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