Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
CopyData Method
See Also  Example
Leadtools Namespace > RasterImage Class : CopyData Method



data
Buffer containing the image new data.
dataOffset
Offset into data where the copy operation should begin.
Updates the data of this RasterImage.

Syntax

Visual Basic (Declaration) 
Public Sub CopyData( _
   ByVal data() As Byte, _
   ByVal dataOffset As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim data() As Byte
Dim dataOffset As Integer
 
instance.CopyData(data, dataOffset)
C# 
public void CopyData( 
   byte[] data,
   int dataOffset
)
C++/CLI 
public:
void CopyData( 
   array<byte>^ data,
   int dataOffset
) 

Parameters

data
Buffer containing the image new data.
dataOffset
Offset into data where the copy operation should begin.

Example

Visual BasicCopy Code
Public Sub CopyDataExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP")

   Dim data As Byte() = New Byte(image.BytesPerLine * image.Height - 1) {}
   Dim val As Integer = 0
   Dim x As Integer = 0
   Do While x < data.Length
      data(x) = CByte(val)
      val += 1
      If val > 255 Then
         val = 0
      End If
      x += 1
   Loop
   image.CopyData(data, 0)

   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "CopyData.bmp", RasterImageFormat.Bmp, 0)

   image.Dispose()
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void CopyDataExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP"); 
 
   byte[] data = new byte[image.BytesPerLine * image.Height]; 
   int val = 0; 
   for(int x = 0; x < data.Length; x++) 
   { 
      data[x] = (byte)val; 
      val++; 
      if(val > 255) 
         val = 0; 
   } 
   image.CopyData(data, 0); 
 
   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "CopyData.bmp", RasterImageFormat.Bmp, 0); 
 
   image.Dispose(); 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

The byte array that you specify will be copied.

The data is copied as is into the internal memory of this RasterImage.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also