×

Discussion Board

Results 1 to 2 of 2

Threaded View

  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

Similar Threads

  1. SMS Filter
    By computerxt in forum Symbian
    Replies: 3
    Last Post: 2010-03-04, 06: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
  •  
×