LEADTOOLS Image File Support (Leadtools.Codecs assembly)

Save(RasterImage,Stream,Int64,RasterImageFormat,Int32,Int32,Int32,Int32,CodecsSavePageMode) Method

Show in webframe







The Leadtools.RasterImage object that holds the image data.
A System.IO.Stream where the image data will be saved.
The offset within the specified stream to embed the saved image file. For example, if you specify 5, then 5 bytes of other data will precede the embedded file.
The output file format. For valid values, Summary of All Supported Image File Formats.
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 closet bits/pixel value supported by that format. For example, if a file format supports 1, 4, and 24 bits/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.
1-based index of the first page in image to save.
1-based index of the last page in image to save. Pass -1 to save from firstPage to the last page in image.
1-based index of the first output page. If the output file already exists, then this parameter lets you control which pages to overwrite and/or where to append the new pages.

Determines how to handle the page when saving to multipage formats. This can be one of the following:

Value Meaning
CodecsSavePageMode.Append Append the new page(s) to the end of the file. If the file does not exist, this option will create the file and add the pages to it. firstSavePageNumber is not used.
CodecsSavePageMode.Insert Insert the new page(s) at the index specified by firstSavePageNumber.
CodecsSavePageMode.Replace Replace the page(s) starting at the index specified by firstSavePageNumber.
CodecsSavePageMode.Overwrite Overwrite the page(s) starting at the index specified by firstSavePageNumber.
Saves the specified image to a stream using an offset within to begin saving.
Syntax
'Declaration
 
Public Overloads Function Save( _
   ByVal image As RasterImage, _
   ByVal stream As Stream, _
   ByVal offset As Long, _
   ByVal format As RasterImageFormat, _
   ByVal bitsPerPixel As Integer, _
   ByVal firstPage As Integer, _
   ByVal lastPage As Integer, _
   ByVal firstSavePageNumber As Integer, _
   ByVal pageMode As CodecsSavePageMode _
) As Long
'Usage
 
Dim instance As RasterCodecs
Dim image As RasterImage
Dim stream As Stream
Dim offset As Long
Dim format As RasterImageFormat
Dim bitsPerPixel As Integer
Dim firstPage As Integer
Dim lastPage As Integer
Dim firstSavePageNumber As Integer
Dim pageMode As CodecsSavePageMode
Dim value As Long
 
value = instance.Save(image, stream, offset, format, bitsPerPixel, firstPage, lastPage, firstSavePageNumber, pageMode)

            

            
 function Leadtools.Codecs.RasterCodecs.Save(RasterImage,Stream,Int64,RasterImageFormat,Int32,Int32,Int32,Int32,CodecsSavePageMode)( 
   image ,
   stream ,
   offset ,
   format ,
   bitsPerPixel ,
   firstPage ,
   lastPage ,
   firstSavePageNumber ,
   pageMode 
)

Parameters

image
The Leadtools.RasterImage object that holds the image data.
stream
A System.IO.Stream where the image data will be saved.
offset
The offset within the specified stream to embed the saved image file. For example, if you specify 5, then 5 bytes of other data will precede the embedded file.
format
The output file format. For valid values, 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 closet bits/pixel value supported by that format. For example, if a file format supports 1, 4, and 24 bits/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.
firstPage
1-based index of the first page in image to save.
lastPage
1-based index of the last page in image to save. Pass -1 to save from firstPage to the last page in image.
firstSavePageNumber
1-based index of the first output page. If the output file already exists, then this parameter lets you control which pages to overwrite and/or where to append the new pages.
pageMode

Determines how to handle the page when saving to multipage formats. This can be one of the following:

Value Meaning
CodecsSavePageMode.Append Append the new page(s) to the end of the file. If the file does not exist, this option will create the file and add the pages to it. firstSavePageNumber is not used.
CodecsSavePageMode.Insert Insert the new page(s) at the index specified by firstSavePageNumber.
CodecsSavePageMode.Replace Replace the page(s) starting at the index specified by firstSavePageNumber.
CodecsSavePageMode.Overwrite Overwrite the page(s) starting at the index specified by firstSavePageNumber.

Return Value

The size of the embedded image file in bytes.
Remarks

You can use this method to embed an image file in another file.

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. Note, however, that the ability to save a region inside a TIFF file must be unlocked. This requires a Document Imaging or Medical Imaging toolkit. For more information, refer to Saving A Region.

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 Leadtools.ImageProcessing.Core.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.

Use FormatSupportsMultipageSave to determine if the format supports saving into a multi-page file.

Use to the SaveImage event to provide progress feedback or to set or modify the saved image data.

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.

In LEADTOOLS version 17 and up, when saving a colored image (such as a 24-bits per pixel image) to bitonal (1-bit per pixel), the RasterCodecs object will not use any dithering when converting the image data. This is done because dithering is not the recommended when converting colored images containing text for document processing such as OCR and Barcode. The resulting text will be fuzzy and hard for a recognition engine to process. To save a colored image as bitonal with Floyd-Stein dithering (the behavior of LEADTOOLS 16.5 and earlier) use CodecsSaveOptions.UseImageDitheringMethod along with RasterImage.DitheringMethod as illustrated below:


            // 'codecs' is the RasterCodecs to use when saving
            // 'image' is a colored RasterImage object
            // Setup FloydStein dithering:
            codecs.Options.Save.UseImageDitheringMethod = true;
            image.DitheringMethod = RasterDitheringMethod.FloydStein;
            // Save the image as 1-bpp with auto-dithering:
            codecs.Save(image, fileName, RasterImageFormat.Tif, 1);
            

For information about quality factors, refer to Compression Quality Factors.

Example
For an example, refer to Save(RasterImage,Stream,Int64,RasterImageFormat,Int32).
Requirements

Target Platforms

See Also

Reference

RasterCodecs Class
RasterCodecs Members
Overload List
Loading and Saving Images
Loading and Saving Large Tiff Files
Speeding Up 1-Bit Documents
Working with Markers
Fast File Info

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.