×

Discussion Board

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

    How to apply a filter to transparent image(png)?

    I'm losing transparency after loading the png into memory..
    This is how I'm loading image..

    Code:
                   using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                    using (var image = isoFile.OpenFile(FilePath, FileMode.Open, FileAccess.Read))
                    {
                        MemoryStream stream = new MemoryStream();
                        image.CopyTo(stream);
                        FgBuffer = stream.GetWindowsRuntimeBuffer();
                        
                        ForegroundGesture.Input = new BufferImageSource(FgBuffer);
                    }
    After loading into IBuffer, I'm using the same as BufferImageSource for applying filters..but i'm losing transparency.
    Is there any way to do it?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    470

    Re: How to apply a filter to transparent image(png)?

    I'm using the same as BufferImageSource for applying filters
    Can you show the code?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

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

    Re: How to apply a filter to transparent image(png)?

    Loading to Buffer
    Code:
    using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                    using (var image = isoFile.OpenFile(FilePath, FileMode.Open, FileAccess.Read))
                    {
                        MemoryStream stream = new MemoryStream();
                        image.CopyTo(stream);
                        App.FgPhotoModel = new FgPhotoModel() { Buffer = stream.GetWindowsRuntimeBuffer() };
                        App.FgPhotoModel.Path = FilePath;
    
                        ForegroundGesture.Input = new BufferImageSource(App.FgPhotoModel.Buffer);
                        stream.Close();
                    }
    Applying Filter to Buffer

    Code:
            /// <summary>
            /// Renders current image with applied filters to the given bitmap.
            /// </summary>
            /// <param name="bitmap">Bitmap to render to</param>
            public async Task RenderBitmapAsync(WriteableBitmap bitmap)
            {
                using (BufferImageSource source = new BufferImageSource(_buffer))
                using (FilterEffect effect = new FilterEffect(source) { Filters = _components })
                using (WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(effect, bitmap))
                {
                    await renderer.RenderAsync();
    
                    bitmap.Invalidate();
                }
            }

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

    Re: How to apply a filter to transparent image(png)?

    Sorry, Just didn't check my filter class properly, I was using JpegRenderer inside the filter class so transparency is lost. Everything is working fine now.

Similar Threads

  1. Replies: 1
    Last Post: 2014-01-29, 19:57
  2. Camera filter with image overlay
    By botja in forum Windows Phone Imaging
    Replies: 7
    Last Post: 2013-10-16, 12:59
  3. Model/view, apply a filter on model
    By remy_david in forum Qt
    Replies: 2
    Last Post: 2011-02-08, 12:16
  4. Drawing SVG image on a transparent mutable Image
    By mkonji in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2010-09-29, 07:14
  5. Filter Image Files
    By siva_321 in forum Symbian
    Replies: 2
    Last Post: 2009-11-09, 10:16

Posting Permissions

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