Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    156

    How to apply list of custom base effects at one time?

    I wanna apply a list of custom base effects at one time like we do with IFilters.
    Is there any way to do it?
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    529

    Re: How to apply list of custom base effects at one time?

    Yes, that is possible. Instead of building an image pipeline that has e.g. a StreamImageSource, a CustomEffectBase-Effect and e.g. a WriteableBitmapRenderer you can simply use the first CustomEffectBase-Effect as the Source of the second one and use the second one as the source for the renderer.

    Code:
    using (BitmapImageSource bis = new BitmapImageSource(src))
    {
    	using(MyEffect1 eff1 = new MyEffect1(bis)//so far pretty much the usual setup
    	{
    		using(MyEffect2 eff2 = new MyEffect2(eff1)//here we now use the eff1 as source of the eff2
    		{
    			using(WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(eff2, bmp)
    			{
    				await renderer.RenderAsync();
    			}
    		}
    	}
    }
    It's not as easy as putting them in an array but this will effectively apply Effect1, then Effect2 and only then write the result out using the specified renderer in a single rendering pass.

  3. #3
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    481

    Re: How to apply list of custom base effects at one time?

    Quote Originally Posted by SB Dev View Post
    It's not as easy as putting them in an array but this will effectively apply Effect1, then Effect2 and only then write the result out using the specified renderer in a single rendering pass.
    If you manage a stack, it should be relatively simple :
    * you can change the source of the first element
    *you can use the last element with sevral renderer.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  4. #4
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    156

    Re: How to apply list of custom base effects at one time?

    I didn't get you Yan, how to manage it?
    Like SB Dev said I can apply all filters at one time.

    But my scenario is like this..
    I've 5 effects, Border, Outline, Outline & Fill, Drop Shadow and Opacity Effects.
    When user applies a filter, I'll add that filter to a List<IFilter/CustomEffectBase> than apply them to the image source.
    The reason for doing the above step is, I want to undo filters later if user want's to.
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    529

    Re: How to apply list of custom base effects at one time?

    Basically you'd just have to do what I did above dynamically whenever you need to change the resulting image.

    The first Effect from your List gets assigned the original image source. The effect at position i in the list gets assigned the effect at position i - 1 as the source. You then assign the last effect in the array as the source for the renderer.

    So the result would look something like this:

    Code:
    effects[0].Source = mySource;
    for(int i = 1; i < effects.Length; i++)
    {
        effects[i].Source = effects[i - 1];
    }
    renderer = new WriteableBitmapRenderer(effects[effects.Length - 1];
    The above code might not work, I did not test it but it should illustrate the concept sufficiently.

  6. #6
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    156

    Re: How to apply list of custom base effects at one time?

    Thanks for the concept, seems to work well. Will try right away and let you know here
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  7. #7
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    481

    Re: How to apply list of custom base effects at one time?

    Quote Originally Posted by SB Dev View Post
    The above code might not work, I did not test it but it should illustrate the concept sufficiently.
    It's the idea .
    And you could extend the concept for IFilter with FilterEffect. when you add a filter
    * if last element is a FIlterEffect => add filter in its IFilter array
    * or create a FIlterEffect and add the IFilter

    Same things for undo.

    I could implement a draft. Several people want this feature
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  8. #8
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    156

    Re: How to apply list of custom base effects at one time?

    Created a List<CustomEffectBase> as you said and stuck up at adding the customEffectBase's to the list.
    How to array these effects?

    ReframingFilter filter = new ReframingFilter(new Windows.Foundation.Rect(pointTL, size), 0);

    using (BufferImageSource source = new BufferImageSource(_buffer))
    using (FilterEffect builtInFilter = new FilterEffect(source) { Filters = _components })
    using (var mainsource = new FilterEffect(builtInFilter) { Filters = new IFilter[] { filter } })
    using (CustomEffectBase borderFilter = new BorderEffect(mainsource))
    using (CustomEffectBase outlineFilter = new Outline(borderFilter))
    using (CustomEffectBase outlineNFillFilter = new OutlineNFill(outlineFilter))
    using (CustomEffectBase dropShadowFilter = new DropShadow(outlineNFillFilter))
    using (CustomEffectBase opacityFilter = new Opacity(dropShadowFilter))
    using (WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(opacityFilter))
    {
    await renderer.RenderAsync();
    }
    Am I doing the right way?
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  9. #9
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    156

    Re: How to apply list of custom base effects at one time?

    I'm at present implementing the same concept for applying and undoing the built-in filters with the use of List<IFilters> and it is working perfectly well. Right now trying to do the same with CustomEffectBase.
    Can I use List<CustomEffectBase> ? Will I run out of memory?
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  10. #10
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    481

    Re: How to apply list of custom base effects at one time?

    Quote Originally Posted by yan_ View Post
    I could implement a draft. Several people want this feature
    I've try to make a manger which manage IFilter, ICustomFilter, CustomFilterBase, SDK effect, ICustomEffect and CustomEffectBase.
    PipelineManager have two functions
    * Add = add an element in pipeline
    * Undo = remove last element

    Once you have added an element you shouldn't dispose it. Manager will do it.
    For ICustomFilter and ICustomEffect , you haven't to use DelegatingXXX. Manager will do it

    You can find the code here :
    https://github.com/yan-verdavaine/wp...ipelineManager
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  11. #11
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    156

    Re: How to apply list of custom base effects at one time?

    You have done an exceptional job like you always does
    Will try to implement the your sample in my app and post results here
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  12. #12
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,573

    Re: How to apply list of custom base effects at one time?

    FYI, this thread has been featured and you can find the details here

Similar Threads

  1. How to apply swipe gestures on each cell of list
    By Manpreet_Singh in forum Mobile Java UI and User Experience
    Replies: 2
    Last Post: 2013-08-20, 11:42
  2. [moved] please help,how to apply custom transition in lwuit
    By vikranttanwar@ in forum Mobile Java UI and User Experience
    Replies: 1
    Last Post: 2013-07-07, 11:42
  3. Replies: 1
    Last Post: 2009-08-27, 20:15
  4. Custom List doesn't view all list items...
    By dusanbaranec in forum Mobile Java General
    Replies: 2
    Last Post: 2005-06-09, 03:10

Posting Permissions

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