×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Blend filter is slower than demo example

    Hi,
    I'm studing the RealtimeBlend Demo and the blend operation in this example is very fast.
    The texture move and pan over the camera frame is very fast.

    I'm trying to make a similar thing but instead of the camera source I have a static image but the blend operation is slow and the drag and pan is jerky.

    This is the blend function

    Code:
    WriteableBitmap wb = new WriteableBitmap(bi.PixelWidth, bi.PixelHeight);
    
    backgroundSource = new StreamImageSource(imgModel.BackgroundImage);
    foregroundImageSource = new StreamImageSource(imgModel.ForegroundImage);
    foregroundMaskSource = new BitmapImageSource(imgModel.MaskBitmap.AsBitmap());
    filterEffect = new FilterEffect(backgroundSource);
    blendFilter = new BlendFilter(foregroundImageSource);
    renderer = new WriteableBitmapRenderer(filterEffect, wb, OutputOption.PreserveAspectRatio);
    
    BlendImages();
    
    private async void BlendImages()
            {
                if (!_rendering)
                {
                    _rendering = true;
                   
                    imgModel.BackgroundImage.Position = 0;
                    imgModel.ForegroundImage.Position = 0;
    
                    blendFilter.Level = 1;
                    blendFilter.MaskSource = foregroundMaskSource;
                    blendFilter.BlendFunction = BlendFunction.Normal;
                    blendFilter.TargetArea = new Windows.Foundation.Rect(
                        _position.X - (_scale / 2),
                        _position.Y - (_scale / 2),
                        _scale,
                        _scale);
                    blendFilter.TargetAreaRotation = _angle;
                    blendFilter.TargetOutputOption = OutputOption.PreserveAspectRatio;
    
                    filterEffect.Filters = new IFilter[] { blendFilter };
    
                    var buffer = await renderer.RenderAsync();
                    FuseImageResult.Source= buffer;
    
                    _rendering = false;
                }
            }
    BlendImages is called after calculating _position and _scale on manipulation event

    What am I doing wrong?

    Thanks
    Damiano
    Last edited by DamMen; 2014-04-11 at 22:41.

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

    Re: Blend filter is slower than demo example

    Hi.
    If FuseImageResult is a Image control, you must set CacheMode in your xaml :
    Code:
    <Image CacheMode="BitmapCache" Stretch="UniformToFill"></Image>
    Personally, i prefer use a canvas with a ImageBrush as background. In my test , it always more efficient.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  3. #3
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Re: Blend filter is slower than demo example

    Quote Originally Posted by yan_ View Post
    Hi.
    If FuseImageResult is a Image control, you must set CacheMode in your xaml :
    Code:
    <Image CacheMode="BitmapCache" Stretch="UniformToFill"></Image>
    Personally, i prefer use a canvas with a ImageBrush as background. In my test , it always more efficient.
    Hi yan_, nice to hear from you again.

    I made some test, the problem is that I am working with a 7/8 MP images and the blend filter is not faster enough for a real time manipulation.
    I decided to try to use low resolution images for the manipulation and then blend the high res images only when the user confirm.

    Do you know a good method to reduce the image resolution?

    I found this #Method 2
    http://developer.nokia.com/community...ne#Sample_code

  4. #4
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Re: Blend filter is slower than demo example

    Hi yan_,

    I changed the Image control with ImageBrush as you suggested and the performance increased!

    Thank you
    Damiano

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

    Re: Blend filter is slower than demo example

    Depend what you want do exactly.
    If you want use only the default blend method, it's better to do the preview directly with XAML. You can look this sample : http://1drv.ms/1kSHF0D
    If you search on the forum, you should find the discution.



    But if you want use other or do more complex filter, you should use Imaging SDK. To improve speed, you could reduce output rendering, llike the sample you have found.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  6. #6
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Re: Blend filter is slower than demo example

    Thank you, great sample.

    I add a mask generated with the Interactive Foreground Segmenter to the blend filter so I have to use Imaging SDK.

  7. #7
    Registered User
    Join Date
    Apr 2014
    Posts
    1

    Re: Blend filter is slower than demo example

    thanks for share

Similar Threads

  1. Problem Call & SMS Filter / Anruf & SMS-Filter OS for Developer Bug?
    By Grisu_1968 in forum Windows Phone General
    Replies: 2
    Last Post: 2014-02-02, 20:16
  2. Replies: 1
    Last Post: 2014-01-29, 20:57
  3. I use http to download,but the speed become slower and slower.
    By flashtao613 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-12-31, 08:34
  4. I use http to download,but the speed become slower and slower.
    By xmnlk in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-10-14, 15:58
  5. Replies: 2
    Last Post: 2008-09-30, 11:01

Posting Permissions

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