×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    7

    "Roll Your Own" Filter

    So in this new version of the SDK I keep reading that you can create your own custom filters...That's nice but why is there no documentation on how to do this?

    I assume it doesnt mean just "stacking" current filters to create "your own"; I'm guessing it is talking pixel manipulation. The only article I can find on it pre-dates the SDK release so I'm guessing this isnt what Nokia means by the new "roll your own" feature.

    http://developer.nokia.com/Community...age_Processors

    Any pointers to where I should look? its nice that Nokia have added something new, but it would be nicer if they added some documentation for it too.

  2. #2
    Registered User
    Join Date
    Aug 2013
    Posts
    7

    Re: "Roll Your Own" Filter

    Ok so now I have found the documentation I am looking for. doh.

    http://developer.nokia.com/Resources...-concepts.html

    Code:
    public class DoubleEffect : CustomEffectBase
    {
        public DoubleEffect(IImageProvider source) : base(source)
        {
        }
    
        protected override void OnProcess(PixelRegion sourcePixelRegion, PixelRegion targetPixelRegion)
        {
            sourcePixelRegion.ForEachRow((index, width, pos) =>
            {
                for (int x = 0; x < width; ++x, ++index)
                {
                    Color c = ToColor(sourcePixelRegion.ImagePixels[index]);
                    c.R = (byte)Math.Min(255, c.R * 2);
                    c.G = (byte)Math.Min(255, c.G * 2);
                    c.B = (byte)Math.Min(255, c.B * 2);
                    targetPixelRegion.ImagePixels[index] = FromColor(c);
                }
            });
        }
    }
    It then says "The resulting DoubleEffect can now be used as any other effect, i.e. as an IImageProvider or as an IImageConsumer."... OK?

    So would this following piece of code be correct? Would this be how I utilise that class?

    Code:
    var renderer = new WriteableBitmapRenderer(DoubleEffect, theBitmap);
    theBitmap = await renderer.RenderAsync()

  3. #3
    Nokia Developer Administrator
    Join Date
    Dec 2013
    Posts
    187

    Re: "Roll Your Own" Filter

    There's good wiki content about this too. Here's one:
    Custom Filter QuickStart for Nokia Imaging SDK

  4. #4
    Registered User
    Join Date
    Jul 2013
    Posts
    12

    Re: "Roll Your Own" Filter

    Here's a quick way to use a custom filter like the DoubleEffect filter you mentioned.

    Drop an image control into your XAML.

    Code:
    <Image x:Name="FilterEffectImage" Width="800" Height="480" Stretch="Fill" Grid.RowSpan="2" />

    Use this code to apply the filter effect to your chosen image and assign it to the XAML image control.

    Code:
    // Initialize a WriteableBitmap with the dimensions of the XAML image control
    WriteableBitmap writeableBitmap = new WriteableBitmap((int)FilterEffectImage.Width, (int)FilterEffectImage.Height);
     
    // Example: Accessing an image stream within a standard photo chooser task callback
    // http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394019(v=vs.105).aspx
    //using (var imageStream = new StreamImageSource(e.ChosenPhoto))
     
    // Example: Accessing an image stream from a sample picture loaded with the project in a folder called "Pictures"
    var resource = App.GetResourceStream(new Uri(string.Concat("Pictures/", "sample_photo_08.jpg"), UriKind.Relative));
    using (var imageStream = new StreamImageSource(resource.Stream))
    {
        // Applying the custom filter effect to the image stream
        using (var customEffect = new DoubleEffect(imageStream))
        {
            // Rendering the resulting image to a WriteableBitmap
            using (var renderer = new WriteableBitmapRenderer(customEffect, writeableBitmap))
            {
                // Applying the WriteableBitmap to our xaml image control
                FilterEffectImage.Source = await renderer.RenderAsync();
            }
        }
    }

    Additionally, you should really take the time to walk through these two outstanding sample projects in detail.

    http://developer.nokia.com/resources...lter-demo.html

    http://developer.nokia.com/resources...-explorer.html
    Last edited by Rob.Kachmar; 2014-01-24 at 05:36.

Similar Threads

  1. How to show you app at the "edit", "apps" and "share" menu of the images.
    By andres.fraga in forum Windows Phone General
    Replies: 6
    Last Post: 2013-03-17, 12:55
  2. Is there a way to "edit" and "save" the "texts" of received SMS messages?
    By pamir_yasti in forum General Development Questions
    Replies: 1
    Last Post: 2010-07-16, 10:15
  3. Replies: 3
    Last Post: 2009-06-18, 21:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •