×

Discussion Board

Page 3 of 3 FirstFirst 123
Results 31 to 41 of 41
  1. #31
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Re: Merge two images

    Quote Originally Posted by yan_ View Post
    The works in application but not in the background agent?
    yes, it fails to render png file

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

    Re: Merge two images

    I've add an agent and copy the code in it and it's work for me.
    How do you access your picture. What is their dimensions?

    [edit] the code : https://skydrive.live.com/redir?resi...86D45C8F7A!105
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

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

    Re: Merge two images

    Load file:
    StorageFile storageFile_top = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///Local/Postit.png"));
    StorageFile storageFile_bg = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///Local/" + tempJPEG));

    Postit.png is 56KB
    tempJPEG is 74.9 KB

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

    Re: Merge two images

    I've found the problem!!!

    var pixels = new int[(int)(session_top.Dimensions.Width * session_top.Dimensions.Height)];
    var bmp = new Bitmap(session_top.Dimensions, ColorMode.Bgra8888, (uint)(4 * session_top.Dimensions.Width), pixels.AsBuffer());

    I've got a missing namespace and the intellisense didn't recognize pixels.AsBuffer() as Int extension.
    I initially thought that the error was the int instead of byte for pixels array so I changed to var pixels = new byte

    Sorry if I waste your time, it was my fault
    Now it works.

  5. #35
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    418

    Re: Merge two images

    No problem.

    So, good news

    In fact you can use a byte array instead of int array. But you use the correct size
    var pixels = new byte[(int)(4*session_top.Dimensions.Width * session_top.Dimensions.Height)];

    Alpha channel will be (normally) every four values. In memory you normally have [B, G, R, A] [B, G, R, A] [B, G, R, A] ...
    Last edited by yan_; 2013-11-09 at 15:07.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

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

    Re: Merge two images

    Ok, I understand the trick.
    I seriously have to study image and filter, there are a lot of useful things to use in a mobile app.

    You are a genius, my app would probably never work without you

  7. #37
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    418

    Re: Merge two images

    The new api have the normal blending
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  8. #38
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Re: Merge two images

    Quote Originally Posted by yan_ View Post
    The new api have the normal blending
    Yeah...I was reading the new documentation right now

  9. #39
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    418

    Re: Merge two images

    Hi,
    it's the update for V1
    Code:
    async void createPicture()
    {
        StorageFile storageFile_top = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/image_top.png"));
        StorageFile storageFile_bg = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/example_bg.jpg"));
    
        using (var source_bg = new StorageFileImageSource(storageFile_bg))
        using (var source_top = new StorageFileImageSource(storageFile_top))
        using (var filters = new FilterEffect(source_bg))
        using (var render = new JpegRenderer(filters))
        {
            filters.Filters = new IFilter[] { new BlendFilter(source_top, BlendFunction.Normal) };
            var buffer = await render.RenderAsync();
           
            var bmp = new BitmapImage();
            bmp.SetSource(buffer.AsStream());
            display.Source = bmp;
        }
    }
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  10. #40
    Registered User
    Join Date
    Nov 2013
    Posts
    30

    Re: Merge two images

    Hi yan_,
    thank you very much for your code, I already have implemented the procedure in the same way.

    For you information I had a memory issue, on the low memory device like Lumia 520, with the previous solution.
    Now with V1 all works good.
    My app is now on certification :-)

  11. #41
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,490

    Re: Merge two images

    For information this thread has been featured with the blog post that can be found at http://developer.nokia.com/Blogs/Com...red-dibo-post/

Page 3 of 3 FirstFirst 123

Similar Threads

  1. How to take screenshot or merge several images
    By PhoneSoulPL in forum Nokia N9
    Replies: 6
    Last Post: 2011-12-21, 09:16
  2. How to merge image?
    By shrawan0786 in forum Geolocation and Navigation
    Replies: 4
    Last Post: 2010-05-03, 08:22
  3. Is it possible to merge two or more DLLs into one?
    By mak_tgi in forum Symbian C++
    Replies: 1
    Last Post: 2009-03-16, 17:19
  4. Merge SIS problem
    By neil.young in forum Python
    Replies: 9
    Last Post: 2008-10-11, 12:23

Posting Permissions

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