×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    145

    How to blend two png images?

    I'm blending two png images with transparency, the background image is losing transparency after blending it. How to prevent it?

    Here is my blend method
    Code:
    public async Task<WriteableBitmap> RenderBorderBitmapAsync()
            {
                Windows.Foundation.Size dimensions = await GetImageSizeAsync();
    
                var newWidth = (int)(dimensions.Width * 1.14);
                var newHeight = (int)(dimensions.Height * 1.14);
    
                WriteableBitmap bitmap = new WriteableBitmap((int)dimensions.Width, (int)dimensions.Height);
                WriteableBitmap bitmapborder = new WriteableBitmap(newWidth, newHeight);
    
                using (BufferImageSource source = new BufferImageSource(_buffer))
                using (FilterEffect foreground = new FilterEffect(source) { Filters = _components })
                using (WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(foreground, bitmap, OutputOption.PreserveAspectRatio))
                {
                    var wbm = await renderer.RenderAsync();
    
                    using (BitmapImageSource resizedimage = new BitmapImageSource(wbm.AsBitmap()))
                    using (CustomEffectBase borderimage = new Border(resizedimage))
                    using (var background = new FilterEffect(borderimage))
                    using (WriteableBitmapRenderer rend = new WriteableBitmapRenderer(background, bitmapborder, OutputOption.PreserveAspectRatio))
                    {
                        BlendFilter blend = new BlendFilter(source);
                        blend.BlendFunction = BlendFunction.Normal;
                        //blend.TargetArea = new Windows.Foundation.Rect((new Windows.Foundation.Point(0.5,0.5), new Windows.Foundation.Size((int)dimensions.Width, (int)dimensions.Height));
                        blend.TargetOutputOption = OutputOption.PreserveSize;
                        background.Filters = new IFilter[] 
                        {
                            blend
                        };
                        await rend.RenderAsync();
                    }
                    
                }
    
                return bitmapborder;
            }
    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
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    145

    Re: How to blend two png images?

    Is there any way to blend two png images?
    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

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to blend two png images?

    If everything else fails, you can still copy the alpha channel.

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

    Re: How to blend two png images?

    Sorry for the noob question, How to copy the alpha channel?
    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
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: How to blend two png images?

    Hi
    when you blend a translucent picture over a translucent picture, the result lost the alpha channel?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

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

    Re: How to blend two png images?

    yeah, I'm losing alpha channel
    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
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: How to blend two png images?

    I haven't dev environnent actually, but if You could make a simple sample which reproduct the bug, we could check and make a bug report.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

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

    Re: How to blend two png images?

    Quote Originally Posted by yan_ View Post
    I haven't dev environnent actually, but if You could make a simple sample which reproduct the bug, we could check and make a bug report.
    Here is the sample which shows my issue
    Download
    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
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    474

    Re: How to blend two png images?

    strang.
    I've make a bug report.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  10. #10
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    145

    Re: How to blend two png images?

    Thank you
    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

Similar Threads

  1. Blend filter is slower than demo example
    By DamMen in forum Windows Phone Imaging
    Replies: 6
    Last Post: 2014-04-22, 15:03
  2. Replies: 3
    Last Post: 2014-02-03, 03:59
  3. Replies: 1
    Last Post: 2014-01-29, 19:57
  4. Replies: 5
    Last Post: 2009-03-09, 08:24
  5. Nokia 6600, Alert's blend out Displayables?
    By ossipetz in forum Mobile Java General
    Replies: 2
    Last Post: 2003-12-10, 13:41

Posting Permissions

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