src/Foundation/Media/Gimela.Media.Imaging/Filters/BaseUsingCopyPartialFilter.cs
/// <summary>
/// Apply filter to an unmanaged image or its part.
/// </summary>
/// 
/// <param name="image">Unmanaged image to apply filter to.</param>
/// <param name="rect">Image rectangle for processing by the filter.</param>
/// 
/// <remarks>The method applies the filter directly to the provided source image.</remarks>
/// 
/// <exception cref="UnsupportedImageFormatException">Unsupported pixel format of the source image.</exception>
/// 
Apply filter to an unmanaged image or its part.
Apply filter to an unmanaged image or its part .
public void ApplyInPlace(UnmanagedImage image, Rectangle rect)
    {
      CheckSourceFormat(image.PixelFormat);
      rect.Intersect(new Rectangle(0, 0, image.Width, image.Height));
      if ((rect.Width | rect.Height) != 0)
      {
        int size = image.Stride * image.Height;
        IntPtr imageCopy = MemoryManager.Alloc(size);
        UnmanagedMemoryHelper.CopyUnmanagedMemory(imageCopy, image.ImageData, size);
        ProcessFilter(
            new UnmanagedImage(imageCopy, image.Width, image.Height, image.Stride, image.PixelFormat),
            image, rect);
        MemoryManager.Free(imageCopy);
      }
    }
public void ApplyInPlace ( UnmanagedImage image , Rectangle rect ) { CheckSourceFormat ( image . PixelFormat ) ; rect . Intersect ( new Rectangle ( 0 , 0 , image . Width , image . Height ) ) ; if ( ( rect . Width | rect . Height ) != 0 ) { int size = image . Stride * image . Height ; IntPtr imageCopy = MemoryManager . Alloc ( size ) ; UnmanagedMemoryHelper . CopyUnmanagedMemory ( imageCopy , image . ImageData , size ) ; ProcessFilter ( new UnmanagedImage ( imageCopy , image . Width , image . Height , image . Stride , image . PixelFormat ) , image , rect ) ; MemoryManager . Free ( imageCopy ) ; } }
Apply filter to an unmanaged image or its part.
Apply filter to an unmanaged image or its part .
// check pixel format of the source image // validate rectangle // process the filter if rectangle is not empty // create a copy of the source image // process the filter
Unsupported pixel format of the source image.
Unsupported pixel format of the source image .
image
UnmanagedImage
Unmanaged image to apply filter to.
Unmanaged image to apply filter to .
rect
Rectangle
Image rectangle for processing by the filter.
Image rectangle for processing by the filter .
remarks
The method applies the filter directly to the provided source image.
The method applies the filter directly to the provided source image .