Save(RasterImage,Stream,RasterImageFormat,int) Method (original) (raw)
Summary
Saves a RasterImage to a stream in any of the supported compressed or uncompressed formats.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (BOOL)save:(LTRasterImage *)_image_
stream:(LTLeadStream *)_stream_
format:(LTRasterImageFormat)_format_
bitsPerPixel:(NSInteger)_bitsPerPixel_
error:(NSError **)error
Parameters
image
The RasterImage object that holds the image data.
stream
A Stream where the image data will be saved.
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 File Formats. If bitsPerPixel is 0, the image will be stored using the closest 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.
Example
This example will load a 24 bits/pixel CMP image and save it to a stream as 1 bits/pixel TIF image.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
public void SaveStream1Example()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_SaveStream1.tif");
// Load the source file (make sure to load as 24 bits/pixel)
RasterImage image = codecs.Load(srcFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1);
Debug.WriteLine("Loaded image has {0} bpp", image.BitsPerPixel);
// Create a stream for the destination file
FileStream fs = File.Create(destFileName);
// Save it as 1 bpp TIF
codecs.Save(image, fs, RasterImageFormat.Tif, 1);
fs.Close();
image.Dispose();
// Check if the image was saved correctly
CodecsImageInfo info = codecs.GetInformation(destFileName, false);
Debug.WriteLine("Saved image has {0} bpp", info.BitsPerPixel);
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools.Codecs Assembly
CompactFile(Stream,Stream,int,int,bool,int,int,bool,int,CodecsSavePageMode,bool,bool) Method
CompactFile(Stream,Stream,int,int,bool,long,int,bool,long,CodecsSavePageMode,bool,bool,bool) Method
CompactFile(string,string,int,int,bool,int,int,bool,int,CodecsSavePageMode,bool,bool) Method
CompactFile(string,string,int,int,bool,long,int,bool,long,CodecsSavePageMode,bool,bool,bool) Method