Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
Save Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : Save Method




Saves a RasterImage to a file in any of the supported compressed or uncompressed formats.

Overload List

OverloadDescription
Save(RasterImage,String,RasterImageFormat,Int32) Saves a RasterImage to a file in any of the supported compressed or uncompressed formats.  
Save(RasterImage,Stream,RasterImageFormat,Int32) Saves a RasterImage to a stream in any of the supported compressed or uncompressed formats.  
Save(RasterImage,String,RasterImageFormat,Int32,Int32,Int32,Int32,CodecsSavePageMode) Saves one or more pages of a RasterImage to a file in any of the supported compressed or uncompressed formats.  
Save(RasterImage,Stream,RasterImageFormat,Int32,Int32,Int32,Int32,CodecsSavePageMode) Saves one or more pages of a RasterImage to a stream in any of the supported compressed or uncompressed formats.  
Save(RasterImage,Stream,Int64,RasterImageFormat,Int32) Saves the specified image to a stream using an offset within to begin saving.  
Save(RasterImage,Stream,Int64,RasterImageFormat,Int32,Int32,Int32,Int32,CodecsSavePageMode) Saves the specified image to a stream using an offset within to begin saving.  

Example

Visual BasicCopy Code
RasterCodecs.Save(RasterImage, string, RasterImageFormat, int)
      Public Sub SaveFile1Example()
         RasterCodecs.Startup()
         Dim codecs As RasterCodecs = New RasterCodecs()

         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_SaveFile1.tif"

         ' Load the source file (make sure to load as 24 bits/pixel)
         Dim image As RasterImage = codecs.Load(srcFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1)
         Console.WriteLine("Loaded image has {0} bpp", image.BitsPerPixel)

         ' Save it as 1 bpp TIF
         codecs.Save(image, destFileName, RasterImageFormat.Tif, 1)
         image.Dispose()

         ' Check if the image was saved correctly
         Dim info As CodecsImageInfo = codecs.GetInformation(destFileName, False)
         Console.WriteLine("Saved image has {0} bpp", info.BitsPerPixel)

         ' Clean up
         codecs.Dispose()
         RasterCodecs.Shutdown()
      End Sub
C#Copy Code
RasterCodecs.Save(RasterImage, string, RasterImageFormat, int) 
      public void SaveFile1Example() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         string srcFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1.cmp"; 
         string destFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image1_SaveFile1.tif"; 
 
         // Load the source file (make sure to load as 24 bits/pixel) 
         RasterImage image = codecs.Load(srcFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1); 
         Console.WriteLine("Loaded image has {0} bpp", image.BitsPerPixel); 
 
         // Save it as 1 bpp TIF 
         codecs.Save(image, destFileName, RasterImageFormat.Tif, 1); 
         image.Dispose(); 
 
         // Check if the image was saved correctly 
         CodecsImageInfo info = codecs.GetInformation(destFileName, false); 
         Console.WriteLine("Saved image has {0} bpp", info.BitsPerPixel); 
 
         // Clean up 
         codecs.Dispose(); 
         RasterCodecs.Shutdown(); 
      }

Remarks

If the output file format supports multipage and then all the pages in image will be saved to the file.

If the image is 8 bits per pixel or greater, use the LEAD CMP format or one of the JPEG (JTIF or JFIF) formats to save disk space.

If the image is 1-bit per pixel, use the LEAD 1-bit format or a CCITT Group 3 or 4 format to save disk space.

If the image has a region, the region stored in the image will be saved, if the image is saved as one of the TIFF file formats. For more information, refer to Saving A Region. Note, however, that the ability to save a region inside a TIFF file must be unlocked. This requires the Document Imaging Toolkit, Document Imaging Suite, Medical Imaging Toolkit, or Medical Imaging Suite.

Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by calling RasterImage.WindowLevel and specifying RasterWindowLevelMode.PaintAndProcessing, by using the WindowLevelCommand or by loading an image from a file format that supports Window Leveling. If a window-leveled image is saved as any other file format, the image data will be converted before being saved. For more information, refer to Saving Window-Leveled Images.

Use the CodecsSaveOptions class to set up other save options parameters before calling this method.

This method supports signed data images, but only DICOM and TIFF formats support signed data. This method will throw an exception if you attempt to save a signed image to a format other than DICOM or TIFF.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also