Constructs a new
RasterImage from the specified existing
RasterImage object.
Syntax
Example
This example derives a new class from then use the RasterImage(RasterImage) constructor.
Visual Basic | Copy Code |
---|
Public Class MyRasterImage : Inherits RasterImage
Private _myData As Integer
Public Sub New(ByVal src As RasterImage)
MyBase.New(src)
_myData = 0
End Sub
Public Property MyData() As Integer
Get
Return _myData
End Get
Set(ByVal value As Integer)
_myData = Value
End Set
End Property
End Class
Public Sub DerivedRasterImage()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"
Dim img As RasterImage = codecs.Load(srcFileName)
Dim myImage As MyRasterImage = New MyRasterImage(img)
img.Dispose()
myImage.PaintGamma = 50
myImage.MyData = 10
Debug.Assert(myImage.PaintGamma = 50)
Debug.Assert(myImage.MyData = 10)
myImage.Dispose()
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub
|
C# | Copy Code |
---|
// A class that derives from RasterImage public 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.Startup(); RasterCodecs codecs = new RasterCodecs(); string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"; // Load the image RasterImage img = codecs.Load(srcFileName); // create a new MyRasterImage instance out of this image MyRasterImage myImage = new MyRasterImage(img); // img is inavlid now and shoule be disposed img.Dispose(); // Now you can use myImage just like any other RasterImage but with your own data myImage.PaintGamma = 50; // RasterImage property myImage.MyData = 10; // MyRasterImage property Debug.Assert(myImage.PaintGamma == 50); Debug.Assert(myImage.MyData == 10); // Clean up myImage.Dispose(); codecs.Dispose(); RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also