LEADTOOLS (Leadtools assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
CopyData Method
See Also 
Leadtools Namespace > RasterImage Class : CopyData Method



data
Buffer containing the image new data.
dataOffset
Offset into data where the copy operation should begin.
data
Buffer containing the image new data.
dataOffset
Offset into data where the copy operation should begin.
Updates the data of this RasterImage. Supported in Silverlight, Windows Phone 7

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()
      Dim codecs As RasterCodecs = New RasterCodecs()
      Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "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, Path.Combine(LEAD_VARS.ImagesDir, "CopyData.bmp"), RasterImageFormat.Bmp, 0)

      image.Dispose()
      codecs.Dispose()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void CopyDataExample()
   {
      RasterCodecs codecs = new RasterCodecs();
      RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "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, Path.Combine(LEAD_VARS.ImagesDir, "CopyData.bmp"), RasterImageFormat.Bmp, 0);

      image.Dispose();
      codecs.Dispose();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
public void CopyDataExample(RasterImage image, Stream destStream)
{
   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);
   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(image, destStream, RasterImageFormat.Png, 0);

   image.Dispose();
}
SilverlightVBCopy Code
Public Sub CopyDataExample(ByVal image As RasterImage, ByVal destStream As Stream)
   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)
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(image, destStream, RasterImageFormat.Png, 0)

   image.Dispose()
End Sub

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: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only), Windows Phone 7

See Also