LEADTOOLS (Leadtools assembly)

CopyDataCommand Class

Show in webframe
Example 







Members 
Copies image data from one image to another.
Object Model
Syntax
public class CopyDataCommand : RasterCommand, IRasterCommand  
'Declaration
 
Public Class CopyDataCommand 
   Inherits RasterCommand
   Implements IRasterCommand 
'Usage
 
Dim instance As CopyDataCommand
public sealed class CopyDataCommand : IRasterCommand  
@interface LTCopyDataCommand : LTRasterCommand
public class CopyDataCommand extends RasterCommand
function Leadtools.ImageProcessing.CopyDataCommand()
public ref class CopyDataCommand : public RasterCommand, IRasterCommand  
Remarks

The destination image must accurately identify the copied data. Therefore, the following properties must specify the same values for both the source and destination images:

The CopyDataCommand works by copying the image data from the image passed to the RasterCommand.Run method to the image passed in the DestinationImage property.

Example
Copy Code  
Imports Leadtools
  Imports Leadtools.Codecs
  Imports Leadtools.ImageProcessing

  Public Sub CopyDataCommandExample()
   Dim codecs As RasterCodecs = New RasterCodecs()

   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
   Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "CopyDataCommand.bmp")

   ' Load the source image from disk
   Dim srcImage As RasterImage = codecs.Load(srcFileName)

   ' Create the destination image with same dimension as the source image
   Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, srcImage.BitsPerPixel, srcImage.Order, srcImage.ViewPerspective, srcImage.GetPalette(), IntPtr.Zero, 0)

   ' Copy the image data from the source image to the destination image
   Dim command As CopyDataCommand = New CopyDataCommand()
   command.DestinationImage = destImage
   command.Run(srcImage)

   ' Save it to disk
   codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24)

   ' Clean Up
   srcImage.Dispose()
   destImage.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;

      
public void CopyDataCommandExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");
   string destFileName = Path.Combine(ImagesPath.Path, "CopyDataCommand.bmp");

   // Load the source image from disk
   RasterImage srcImage = codecs.Load(srcFileName);

   // Create the destination image with same dimension as the source image
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      srcImage.Width,
      srcImage.Height,
      srcImage.BitsPerPixel,
      srcImage.Order,
      srcImage.ViewPerspective,
      srcImage.GetPalette(),
      IntPtr.Zero,
      0);

   // Copy the image data from the source image to the destination image
   CopyDataCommand command = new CopyDataCommand();
   command.DestinationImage = destImage;
   command.Run(srcImage);

   // Save it to disk
   codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24);

   // Clean Up
   srcImage.Dispose();
   destImage.Dispose();
   codecs.Dispose();
}
RasterCommandExamples.prototype.CopyDataCommandExample = function () {
    Tools.SetLicense();
    with (Leadtools) {
        with (Leadtools.Codecs) {
            with (Leadtools.ImageProcessing) {
                var codecs = new RasterCodecs();

                var srcFileName = "Assets\\Image1.cmp";
                var destFileName = "CopyDataCommand.bmp";
                var srcImage;
                var destImage;
                // Load the source image from disk
                return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
                    return codecs.loadAsync(LeadStreamFactory.create(loadFile))
                })
                    .then(function (img) {
                        srcImage = img;

                        // Create the destination image with same dimension as the source image
                        destImage = new RasterImage(
                           RasterMemoryFlags.conventional,
                           srcImage.width,
                           srcImage.height,
                           srcImage.bitsPerPixel,
                           srcImage.order,
                           srcImage.viewPerspective,
                           srcImage.getPalette());

                        // Copy the image data from the source image to the destination image
                        var command = new CopyDataCommand();
                        command.destinationImage = destImage;
                        command.run(srcImage);

                        // Save it to disk
                        return Tools.AppLocalFolder().createFileAsync(destFileName)
                    })
                    .then(function (saveFile) {
                        return codecs.saveAsync(destImage, LeadStreamFactory.create(saveFile), RasterImageFormat.bmp, 24)
                    })
                    .then(function () {

                        // Clean Up
                        srcImage.close();
                        destImage.close();
                        codecs.close();
                    });
            }
        }
    }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;

      
public async Task CopyDataCommandExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = @"Assets\Image1.cmp";
   string destFileName = @"CopyDataCommand.bmp";

   // Load the source image from disk
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage srcImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // Create the destination image with same dimension as the source image
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      srcImage.Width,
      srcImage.Height,
      srcImage.BitsPerPixel,
      srcImage.Order,
      srcImage.ViewPerspective,
      srcImage.GetPalette());

   // Copy the image data from the source image to the destination image
   CopyDataCommand command = new CopyDataCommand();
   command.DestinationImage = destImage;
   command.Run(srcImage);

   // Save it to disk
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
   await codecs.SaveAsync(destImage, LeadStreamFactory.Create(saveFile), RasterImageFormat.Bmp, 24);

   // Clean Up
   srcImage.Dispose();
   destImage.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;

public void CopyDataCommandExample(RasterImage srcImage, Stream destStream)
{
   RasterCodecs codecs = new RasterCodecs();
   // Create the destination image with same dimension as the source image
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      srcImage.Width,
      srcImage.Height,
      srcImage.BitsPerPixel,
      srcImage.Order,
      srcImage.ViewPerspective,
      srcImage.GetPalette(),
      null,
      0);

   // Copy the image data from the source image to the destination image
   CopyDataCommand command = new CopyDataCommand();
   command.DestinationImage = destImage;
   command.Run(srcImage);

   // Save it to disk
   codecs.Save(destImage, destStream, RasterImageFormat.Bmp, 24);

   // Clean Up
   srcImage.Dispose();
   destImage.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Media

Public Sub CopyDataCommandExample(ByVal srcImage As RasterImage, ByVal destStream As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Create the destination image with same dimension as the source image
   Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, srcImage.BitsPerPixel, srcImage.Order, srcImage.ViewPerspective, srcImage.GetPalette(), Nothing, 0)

   ' Copy the image data from the source image to the destination image
   Dim command As CopyDataCommand = New CopyDataCommand()
   command.DestinationImage = destImage
   command.Run(srcImage)

   ' Save it to disk
   codecs.Save(destImage, destStream, RasterImageFormat.Bmp, 24)

   ' Clean Up
   srcImage.Dispose()
   destImage.Dispose()
End Sub
Requirements

Target Platforms

See Also

Reference

CopyDataCommand Members
Leadtools.ImageProcessing Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.