×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    8

    BUG: Blur filter with transparent Blend filter in *same* session produces artifacts

    This is for Nokia Imaging SDK.



    Repro steps:
    1. Have an image without transparency
    2. Have an image with transparency.
    3. Open editing session for image #1 and add Blur filter with any BlurLevel other than Blur0.
    4. Add Blend filter using image #2 as parameter, specify BlendFunction.Add

    Result:
    Clearly visible grid effect from blur filter.

    Workaround:
    In Step #3 above render the session and close it. Then in Step #4 open a new session for already blurred image and apply blending.

    Sample code to reproduce. This uses my ColorMatrixFilter to add transparency to an image. Here I'm trying to achieve "smooth glow" effect.
    Code:
    	//the bitmap variable is the non-transparent image
    	//the overlay is the transparent image
    	var overlay = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight);
    	using (var session = new EditingSession(bitmap.AsBitmap()))
    	{
    		session.AddFilter(FilterFactory.CreateContrastFilter(0.1));
    		session.AddFilter(FilterFactory.CreateHueSaturationFilter(128, (uint) (128 *1.1 + 0.5)));
    
    		await session.RenderToWriteableBitmapAsync(overlay);
    	}
    
    	//adding the transparency
    	var matrix = new ColorMatrixFilter(alpha: new[] {0, 0, 0, 0.4f});
    	await matrix.ApplyAsync(overlay);
    
    	//blending here produces a very visible grid on the resulting image
    	using (var session = new EditingSession(bitmap.AsBitmap()))
    	using (var blending = new EditingSession(overlay.AsBitmap()))
    	{
    		session.AddFilter(FilterFactory.CreateBlurFilter(BlurLevel.Blur1));
    		session.AddFilter(FilterFactory.CreateBlendFilter(blending, BlendFunction.Add));
    
    		await session.RenderToWriteableBitmapAsync(bitmap);
    	}
    Same code with the workaround applied:
    Code:
    	var overlay = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight);
    	using (var session = new EditingSession(bitmap.AsBitmap()))
    	{
    		session.AddFilter(FilterFactory.CreateContrastFilter(0.1));
    		session.AddFilter(FilterFactory.CreateHueSaturationFilter(128, (uint) (128 *1.1 + 0.5)));
    
    		await session.RenderToWriteableBitmapAsync(overlay);
    	}
    
    	var matrix = new ColorMatrixFilter(alpha: new[] {0, 0, 0, 0.4f});
    	await matrix.ApplyAsync(overlay);
    
    	using (var session = new EditingSession(bitmap.AsBitmap()))
    	{
    		session.AddFilter(FilterFactory.CreateBlurFilter(BlurLevel.Blur1));
    
    		await session.RenderToWriteableBitmapAsync(bitmap);
    	}
    
    	using (var session = new EditingSession(bitmap.AsBitmap()))
    	using (var blending = new EditingSession(overlay.AsBitmap()))
    	{
    		session.AddFilter(FilterFactory.CreateBlendFilter(blending, BlendFunction.Add));
    
    		await session.RenderToWriteableBitmapAsync(bitmap);
    	}
    Last edited by vishnevetskaya; 2013-10-08 at 06:53. Reason: adding sample code

  2. #2
    Nokia Developer Administrator
    Join Date
    Dec 2013
    Posts
    293

    Re: BUG: Blur filter with transparent Blend filter in *same* session produces artifac

    Thank you for reporting this issue. It's been a while since it was reported and you've likely moved on to other things, but in case it's still helpful, I wanted to respond.

    The Imaging SDK does not currently support in-place rendering (rendering to the same buffer as the source buffer). The various filters of the SDK have been optimized with the assumption that the destination buffer is not the same as the input buffer. That allows us to avoid quite a few copy operations, and to be as fast as possible. There are no plans to support in-place rendering. However, the SDK should really throw an error every time it gets such a request, to warn you that you’re doing something unsupported. We will add that protection in a future build.

    Another workaround for the scenario you proposed is simply to render the final bitmap to a new WriteableBitmap and not try to reuse existing bitmap.

Similar Threads

  1. SMS Filter
    By computerxt in forum Symbian
    Replies: 3
    Last Post: 2010-03-04, 05:55
  2. Replies: 2
    Last Post: 2008-09-30, 11:01
  3. URL filter
    By liuxingyu_best in forum Symbian
    Replies: 1
    Last Post: 2008-08-27, 14:19
  4. filter incoming sms on S60 3rd (silent filter)
    By kompotFX in forum Symbian
    Replies: 3
    Last Post: 2006-09-08, 08: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
  •  
×