src/Foundation/Media/Gimela.Media.Imaging/Filters/BaseFilter.cs
/// <summary>
/// Apply filter to an image.
/// </summary>
/// 
/// <param name="imageData">Source image to apply filter to.</param>
/// 
/// <returns>Returns filter's result obtained by applying the filter to
/// the source image.</returns>
/// 
/// <remarks>The filter accepts bitmap data as input and returns the result
/// of image processing filter as new image. The source image data are kept
/// unchanged.</remarks>
///
/// <exception cref="UnsupportedImageFormatException">Unsupported pixel format of the source image.</exception>
///
Apply filter to an image.
Apply filter to an image .
public Bitmap Apply(BitmapData imageData)
    {
      CheckSourceFormat(imageData.PixelFormat);
      int width = imageData.Width;
      int height = imageData.Height;
      PixelFormat dstPixelFormat = FormatTranslations[imageData.PixelFormat];
      Bitmap dstImage = (dstPixelFormat == PixelFormat.Format8bppIndexed) ?
          Gimela.Media.Imaging.ImageHelper.CreateGrayscaleImage(width, height) :
          new Bitmap(width, height, dstPixelFormat);
      BitmapData dstData = dstImage.LockBits(
         new Rectangle(0, 0, width, height),
         ImageLockMode.ReadWrite, dstPixelFormat);
      try
      {
        ProcessFilter(new UnmanagedImage(imageData), new UnmanagedImage(dstData));
      }
      finally
      {
        dstImage.UnlockBits(dstData);
      }
      return dstImage;
    }
public Bitmap Apply ( BitmapData imageData ) { CheckSourceFormat ( imageData . PixelFormat ) ; int width = imageData . Width ; int height = imageData . Height ; PixelFormat dstPixelFormat = FormatTranslations [ imageData . PixelFormat ] ; Bitmap dstImage = ( dstPixelFormat == PixelFormat . Format8bppIndexed ) ? Gimela . Media . Imaging . ImageHelper . CreateGrayscaleImage ( width , height ) : new Bitmap ( width , height , dstPixelFormat ) ; BitmapData dstData = dstImage . LockBits ( new Rectangle ( 0 , 0 , width , height ) , ImageLockMode . ReadWrite , dstPixelFormat ) ; try { ProcessFilter ( new UnmanagedImage ( imageData ) , new UnmanagedImage ( dstData ) ) ; } finally { dstImage . UnlockBits ( dstData ) ; } return dstImage ; }
Apply filter to an image.
Apply filter to an image .
// check pixel format of the source image // get width and height // destination image format // create new image of required format // lock destination bitmap data // process the filter // unlock destination images
Returns filter's result obtained by applying the filter to
the source image.
Returns filter ' s result obtained by applying the filter to the source image .
Unsupported pixel format of the source image.
Unsupported pixel format of the source image .
imageData
BitmapData
Source image to apply filter to.
Source image to apply filter to .
remarks
The filter accepts bitmap data as input and returns the result
of image processing filter as new image. The source image data are kept
unchanged.
The filter accepts bitmap data as input and returns the result of image processing filter as new image . The source image data are kept unchanged .