Save(Stream,EncoderBase) Method (VintasoftImage)
Saves this
VintasoftImage object to the specified stream using specified encoder.
Supported image formats: BMP, GIF, JBIG2, JPEG, PCX, PDF, PNG, TIFF.
Suitable encoder is selected automatically from the extension of the filename, exception is thrown if encoder is not found for file extension specified in filename.
If image is saving to new file (stream != SourceInfo.Stream) this method:
- saves image to new BMP/GIF/JBIG2/JPEG/PCX/PDF/PNG/TIFF file if MultipageEncoderBase.CreateNewFile = true; file specified by filename is replaced if it exists
- saves image to new JBIG2/PDF/TIFF file if MultipageEncoderBase.CreateNewFile = false and file specified by filename is not exist
- adds image to new JBIG2/PDF/TIFF file if MultipageEncoderBase.CreateNewFile = false and file specified by filename is exist
If image is saving to the source file (
stream ==
SourceInfo.Stream) this method:
- saves image to the source BMP/GIF/JBIG2/JPEG/PCX/PDF/PNG/TIFF file if image is changed (IsChanged = true) and source file contains only one image
- throws an exception if image is saved to the source BMP/GIF/JBIG2/JPEG/PCX/PDF/PNG/TIFF file and image is not changed (IsChanged = false)
- adds image to the source JBIG2/PDF/TIFF file if MultipageEncoderBase.CreateNewFile = false, file specified by filename is exist
This C#/VB.NET code shows how to load image from disk and save it to memory as JPEG stream.
' load image from file
Using image As New Vintasoft.Imaging.VintasoftImage("c:\original-image.tif")
Dim memory As New System.IO.MemoryStream()
' create JPEG encoder
Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.JpegEncoder(New Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings(10))
' save annotations with image
encoder.AnnotationsFormat = Vintasoft.Imaging.AnnotationsFormat.VintasoftBinary
' save image to file
image.Save(memory, encoder)
End Using
// load image from file
using (Vintasoft.Imaging.VintasoftImage image =
new Vintasoft.Imaging.VintasoftImage(@"c:\original-image.tif"))
{
System.IO.MemoryStream memory = new System.IO.MemoryStream();
// create JPEG encoder
Vintasoft.Imaging.Codecs.Encoders.JpegEncoder encoder =
new Vintasoft.Imaging.Codecs.Encoders.JpegEncoder(
new Vintasoft.Imaging.Codecs.Encoders.JpegEncoderSettings(10));
// save annotations with image
encoder.AnnotationsFormat = Vintasoft.Imaging.AnnotationsFormat.VintasoftBinary;
// save image to file
image.Save(memory, encoder);
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5