public RasterImage(RasterImage srcImage)
Public Function New( _ByVal srcImage As RasterImage _)
- (nullable instancetype)initWithImage:(LTRasterImage *)rasterImage error:(NSError **)error public RasterImage(RasterImage srcImage) public:RasterImage(RasterImage^ srcImage)
srcImage
The RasterImage from which to create the new RasterImage.
This constructor will "pull" all the internal data (image pages, metadata, etc) from srcImage and puts a copy of them into the newly created RasterImage.
After calling this constructor, srcImage remains valid and changes to its properties or data will not affect the newly created RasterImage object.
This constructor is useful when deriving your own classes from RasterImage as shown in the example below.
For more information, refer to Grayscale Images.
This example derives a new class from then use the RasterImage(RasterImage) constructor.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Dicom;using Leadtools.Drawing;using Leadtools.Controls;using LeadtoolsExamples.Common;using Leadtools.Svg;// A class that derives from RasterImagepublic class MyRasterImage : RasterImage{private int _myData;public MyRasterImage(RasterImage src):base(src){_myData = 0;}public int MyData{get{return _myData;}set{_myData = value;}}}public void DerivedRasterImage(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");// Load the imageRasterImage img = codecs.Load(srcFileName);// create a new MyRasterImage instance out of this imageMyRasterImage myImage = new MyRasterImage(img);// img is inavlid now and shoule be disposedimg.Dispose();// Now you can use myImage just like any other RasterImage but with your own datamyImage.PaintGamma = 50; // RasterImage propertymyImage.MyData = 10; // MyRasterImage propertyAssert.IsTrue(myImage.PaintGamma == 50);Assert.IsTrue(myImage.MyData == 10);// Clean upmyImage.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.Svg' A class that derives from RasterImagePublic Class MyRasterImage : Inherits RasterImagePrivate _myData As IntegerPublic Sub New(ByVal src As RasterImage)MyBase.New(src)_myData = 0End SubPublic Property MyData() As IntegerGetReturn _myDataEnd GetSet(ByVal value As Integer)_myData = valueEnd SetEnd PropertyEnd ClassPublic Sub DerivedRasterImage()Dim codecs As RasterCodecs = New RasterCodecs()Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")' Load the imageDim img As RasterImage = codecs.Load(srcFileName)' create a new MyRasterImage instance out of this imageDim myImage As MyRasterImage = New MyRasterImage(img)' img is inavlid now and shoule be disposedimg.Dispose()' Now you can use myImage just like any other RasterImage but with your own datamyImage.PaintGamma = 50 ' RasterImage propertymyImage.MyData = 10 ' MyRasterImage propertyDebug.Assert(myImage.PaintGamma = 50)Debug.Assert(myImage.MyData = 10)' Clean upmyImage.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
c#[Silverlight C# Example]using Leadtools;using Leadtools.Codecs;using Leadtools.Dicom;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Examples;using Leadtools.Windows.Media;// A class that derives from RasterImagepublic class MyRasterImage : RasterImage{private int _myData;public MyRasterImage(RasterImage src):base(src){_myData = 0;}public int MyData{get{return _myData;}set{_myData = value;}}}public void DerivedRasterImage(RasterImage srcImage){// create a new MyRasterImage instance out of this imageMyRasterImage myImage = new MyRasterImage(srcImage);// srcImage is inavlid now and should be disposedsrcImage.Dispose();// Now you can use myImage just like any other RasterImage but with your own datamyImage.TransparentColor = RasterColorConverter.FromColor(Colors.Blue); // RasterImage propertymyImage.MyData = 10; // MyRasterImage propertyDebug.Assert(myImage.MyData == 10);// Clean upmyImage.Dispose();}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DicomImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.Media' A class that derives from RasterImagePublic Class MyRasterImage : Inherits RasterImagePrivate _myData As IntegerPublic Sub New(ByVal src As RasterImage)MyBase.New(src)_myData = 0End SubPublic Property MyData() As IntegerGetReturn _myDataEnd GetSet_myData = ValueEnd SetEnd PropertyEnd ClassPublic Sub DerivedRasterImage(ByVal srcImage As RasterImage)' create a new MyRasterImage instance out of this imageDim myImage As MyRasterImage = New MyRasterImage(srcImage)' srcImage is inavlid now and should be disposedsrcImage.Dispose()' Now you can use myImage just like any other RasterImage but with your own datamyImage.TransparentColor = RasterColorConverter.FromColor(Colors.Blue) ' RasterImage propertymyImage.MyData = 10 ' MyRasterImage propertyDebug.Assert(myImage.MyData = 10)' Clean upmyImage.Dispose()End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
