BlendFilter Class

Blends an image source onto the image using a blend function.

Inheritance Hierarchy

System..::..Object  Nokia.Graphics.Imaging..::..BlendFilter

Namespace: Nokia.Graphics.ImagingAssembly: Nokia.Graphics.Imaging (in Nokia.Graphics.Imaging.dll) Version: 255.255.255.255

Syntax

C#
public sealed class BlendFilter : IClosable, 
	IFilter, __IBlendFilterPublicNonVirtuals
Visual Basic
Public NotInheritable Class BlendFilter 
	Implements IClosable, IFilter, __IBlendFilterPublicNonVirtuals
Visual C++
public ref class BlendFilter sealed : IClosable, 
	IFilter, __IBlendFilterPublicNonVirtuals

Examples

C#

This sample takes CameraCaptureTask result photo and applies a filter to it.

Universal apps:

private async void captureButton_Click(object sender, RoutedEventArgs e)
{
    await mediaCapture.StopPreviewAsync();

    var stream = new InMemoryRandomAccessStream();
    await mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream);
    stream.Seek(0);

    using (var source = new RandomAccessStreamImageSource(stream, ImageFormat.Jpeg))
    {
        // Create effect collection with the source stream
        using (var filters = new FilterEffect(source))
        {
            using (
                var colorSource = new ColorImageSource(
                    new Windows.Foundation.Size(
                        (int)(Window.Current.Bounds.Width), 
                        (int)(Window.Current.Bounds.Height)),
                    Windows.UI.Color.FromArgb(255, 255, 0, 0)))
            {
                // Initialize the filter with foreground image source, blendfunction and level
                var sampleFilter = new BlendFilter(colorSource, BlendFunction.Colorburn, 0.8);

                // Add the filter to the FilterEffect collection
                filters.Filters = new IFilter[] { sampleFilter };

                // Create a target where the filtered image will be rendered to
                var target = new WriteableBitmap((int)(Window.Current.Bounds.Width), (int)(Window.Current.Bounds.Height));

                // Create a new renderer which outputs WriteableBitmaps
                using (var renderer = new WriteableBitmapRenderer(filters, target))
                {
                    // Render the image with the filter(s)
                    await renderer.RenderAsync();

                    // Set the output image to Image control as a source
                    ImageControl.Source = target;
                }
            }
        }
    }
}

Silverlight:

async void CaptureTask_Completed(object sender, PhotoResult e)
{
    // Create a source to read the image from PhotoResult stream
    using (var source = new StreamImageSource(e.ChosenPhoto))
    {
        // Create effect collection with the source stream
        using (var filters = new FilterEffect(source))
        {
            using (
                var colorSource = new ColorImageSource(
                    new Windows.Foundation.Size(
                        (int)ImageControl.ActualWidth, 
                        (int)ImageControl.ActualHeight),
                    Windows.UI.Color.FromArgb(255, 255, 0, 0)))
            {
                // Initialize the filter with foreground image source, blendfunction and level
                var sampleFilter = new BlendFilter(colorSource, BlendFunction.Colorburn, 0.8);

                // Add the filter to the FilterEffect collection
                filters.Filters = new IFilter[] {sampleFilter};

                // Create a target where the filtered image will be rendered to
                var target = new WriteableBitmap((int) ImageControl.ActualWidth, (int) ImageControl.ActualHeight);

                // Create a new renderer which outputs WriteableBitmaps
                using (var renderer = new WriteableBitmapRenderer(filters, target))
                {
                    // Render the image with the filter(s)
                    await renderer.RenderAsync();

                    // Set the output image to Image control as a source
                    ImageControl.Source = target;
                }
            }
        }
    }
}
Visual Basic


Visual C++



Last updated 19 June 2014

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×