This constructor is required by ISerializable.
info
The data needed to serialize or deserialize an object.
context
The source and destination of a given serialized stream.
The RasterImage class supports standard .NET serialization. Serialization of a RasterImage is the process of converting the state of a RasterImage object into a form that can be persisted or transported. The complement of serialization is deserialization, which converts a stream into an RasterImage object. Together, these processes allow the image data to be easily stored and transferred.
When you serialize an RasterImage object, all the data inside the object are saved. This includes the image data of all pages as well as the current page number, region information, low bit/high bit, palette data, metadata (tags, markers and comments), etc. In other words, the RasterImage can be constructed back to its original state from the stream.
For more information and examples regarding serialization of an RasterImage object, refer to RasterImage Serialization.
For more information, refer to Grayscale Images.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using LeadtoolsExamples.Common;public void MyRasterImageSerializationTest(){// Load an imageRasterCodecs codecs = new RasterCodecs();RasterImage img = codecs.Load(Path.Combine(ImagesPath.Path, "Image1.cmp"));// create a new MyRasterImage instance out of this imageMyRasterImage myImage = new MyRasterImage(img);// Set our custom datamyImage.MyIntegerData = 10;myImage.MyStringData = "My string";string msg = string.Format("Before serialization. MyIntegerData = {0}, MyStringData = {1}", myImage.MyIntegerData, myImage.MyStringData);MessageBox.Show(msg);// img is invalid now and should be disposedimg.Dispose();// Serialize myImageBinaryFormatter formatter = new BinaryFormatter();MemoryStream ms = new MemoryStream();formatter.Serialize(ms, myImage);// dispose myImagemyImage.Dispose();myImage = null;// Deserialize back from the streamms.Position = 0;myImage = formatter.Deserialize(ms) as MyRasterImage;msg = string.Format("After serialization. MyIntegerData = {0}, MyStringData = {1}", myImage.MyIntegerData, myImage.MyStringData);Console.WriteLine(msg);// re-save the imagecodecs.Save(myImage, Path.Combine(ImagesPath.Path, "Image1_MySerialized.bmp"), RasterImageFormat.Bmp, 24);// Clean upms.Close();ms.Dispose();myImage.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorPublic Sub MyRasterImageSerializationTest()' Load an imageDim codecs As RasterCodecs = New RasterCodecs()Dim img As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))' create a new MyRasterImage instance out of this imageDim myImage As MyRasterImage = New MyRasterImage(img)' Set our custom datamyImage.MyIntegerData = 10myImage.MyStringData = "My string"Dim msg As String = String.Format("Before serialization. MyIntegerData = {0}, MyStringData = {1}", myImage.MyIntegerData, myImage.MyStringData)MessageBox.Show(msg)' img is invalid now and should be disposedimg.Dispose()' Serialize myImageDim formatter As BinaryFormatter = New BinaryFormatter()Dim ms As MemoryStream = New MemoryStream()formatter.Serialize(ms, myImage)' dispose myImagemyImage.Dispose()myImage = Nothing' Deserialize back from the streamms.Position = 0myImage = CType(formatter.Deserialize(ms), MyRasterImage)msg = String.Format("After serialization. MyIntegerData = {0}, MyStringData = {1}", myImage.MyIntegerData, myImage.MyStringData)MessageBox.Show(msg)' re-save the imagecodecs.Save(myImage, Path.Combine(LEAD_VARS.ImagesDir, "Image1_MySerialized.bmp"), RasterImageFormat.Bmp, 24)' Clean upms.Close()myImage.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
|
Products |
Support |
Feedback: RasterImage Constructor(SerializationInfo,StreamingContext) - Leadtools |
Introduction |
Help Version 19.0.2017.6.19
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.