Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.6.28
|
Leadtools Namespace > RasterImage Class > CopyData Method : CopyData(IBuffer,Int32) Method |
public void CopyData( IBuffer data, int dataOffset )
'Declaration
Public Overloads Sub CopyData( _ ByVal data As IBuffer, _ ByVal dataOffset As Integer _ )
'Usage
Dim instance As RasterImage Dim data As IBuffer Dim dataOffset As Integer instance.CopyData(data, dataOffset)
public void CopyData( IBuffer data, int dataOffset )
function Leadtools.RasterImage.CopyData(IBuffer,Int32)( data , dataOffset )
public: void CopyData( IBuffer^ data, int dataOffset )
The byte array that you specify will be copied.
The data is copied as is into the internal memory of this RasterImage.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Core Imports Leadtools.ImageProcessing.Color Imports Leadtools.Controls Imports Leadtools.Dicom Imports Leadtools.Drawing Imports Leadtools.Svg 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
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 Leadtools.Svg; public void CopyDataExample() { RasterCodecs codecs = new RasterCodecs(); RasterImage image = codecs.Load(Path.Combine(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, Path.Combine(ImagesPath.Path, "CopyData.bmp"), RasterImageFormat.Bmp, 0); image.Dispose(); codecs.Dispose(); }
RasterImageExamples.prototype.CopyDataExample = function () { Tools.SetLicense(); with (Leadtools) { with (Leadtools.Codecs) { var codecs = new RasterCodecs(); var srcFileName = "Assets\\Image1.cmp"; var image; return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) { return codecs.loadAsync(LeadStreamFactory.create(loadFile)) }) .then(function (img) { image = img; var data = new Array(image.bytesPerLine * image.height); var val = 0; for (var x = 0; x < data.length; x++) { data[x] = val; val++; if (val > 255) val = 0; } image.copyData(data, 0); return Tools.AppLocalFolder().createFileAsync("CopyData.bmp") }) .then(function (saveFile) { var saveStream = LeadStreamFactory.create(saveFile); return codecs.saveAsync(image, saveStream, RasterImageFormat.bmp, 0) }) .then(function () { image.close(); codecs.close(); }); } } }
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; using Leadtools.ImageProcessing.Color; using Leadtools.Dicom; public async Task CopyDataExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = @"Assets\Image1.cmp"; StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); 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); StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("CopyData.bmp"); ILeadStream saveStream = LeadStreamFactory.Create(saveFile); await codecs.SaveAsync(image, saveStream, RasterImageFormat.Bmp, 0); image.Dispose(); codecs.Dispose(); }
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; 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(); }
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Dicom Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Core Imports Leadtools.ImageProcessing.Color Imports Leadtools.Windows.Media 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