public void Copy( UnmanagedImage destImage )
{
if (
( width != destImage.width ) || ( height != destImage.height ) ||
( pixelFormat != destImage.pixelFormat ) )
{
throw new InvalidImagePropertiesException( "Destination image has different size or pixel format." );
}
if ( stride == destImage.stride )
{
// copy entire image
AForge.SystemTools.CopyUnmanagedMemory( destImage.imageData, imageData, stride * height );
}
else
{
unsafe
{
int dstStride = destImage.stride;
int copyLength = ( stride < dstStride ) ? stride : dstStride;
byte* src = (byte*) imageData.ToPointer( );
byte* dst = (byte*) destImage.imageData.ToPointer( );
// copy line by line
for ( int i = 0; i < height; i++ )
{
AForge.SystemTools.CopyUnmanagedMemory( dst, src, copyLength );
dst += dstStride;
src += stride;
}
}
}
}