×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    8

    Cutted image and back button

    Uff I don't know how to explain my problem... I'll try to be clearer as possible...

    So... the situasion is the following...
    I have a MainPage.xaml and a ChoosenPhoto.xaml

    In MainPage I choose an image from the media library using the PhotoChooserTask and then I redirect to ChoosenPhoto. In ChoosenPhoto I apply a filter to the photo and I show It...
    No problem.
    I click back button and i do the same action!
    The filter is applied to top half photo and the bottom half is not shown (or better, the bottom half is shown of just one color, grey, beige.. depend from the filter applied)..

    I think it could be the cache of the image (perhaps the preceding image could create some problem?).. I have tried to set the source of the image = null, and then to set the source to the stream of the new chosen image.

    What could be? thanx...

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    520

    Re: Cutted image and back button

    I'm trying to understand the process so I'll just reiterate what your App is doing:

    1.) Open MainPage and choose a photo from the library - the chosen photo is stored in a stream?
    2.) Navigate to the ChosenPhotoPage - how do you pass the photo? is it stored in a static variable? in what method do you process the image (OnNavigatedTo)?

    This process works fine when choosing the first image but the issue appears when you try the second, third, etc. image?

    Can you post the code that you're using to create the stream, read the stream and apply the filter? Perhaps we can see some error there (e.g. buffer length limitation, etc.)

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    475

    Re: Cutted image and back button

    I 99% sure it's because WP display your picture before the rendering is finished. It's similar to this : http://developer.nokia.com/Community...her_correction

    (I thinks sdk use wavelet transformation.)

    In simple, add invalidate after rendering. A better solution is to create a new WriteableableBitmap when you make a new rendering and set as Image control source after the rendering.
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  4. #4
    Registered User
    Join Date
    Mar 2013
    Posts
    8

    Re: Cutted image and back button

    Quote Originally Posted by SB Dev View Post
    I'm trying to understand the process so I'll just reiterate what your App is doing:

    1.) Open MainPage and choose a photo from the library - the chosen photo is stored in a stream?
    yes

    Quote Originally Posted by SB Dev View Post
    2.) Navigate to the ChosenPhotoPage - how do you pass the photo? is it stored in a static variable? in what method do you process the image (OnNavigatedTo)?
    "Context" is a my own class that contain a property "ChosenPhoto" that is a simple "Stream"
    Code:
            protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
            {
                try
                {
                        ...
    
                        App.Context.ChosenPhoto = Utilities.GetPhoto(queryStrings["token"]);
    
                        queryStrings.Remove(QUERYSTRING_TOKEN);
    
                        NavigationService.Navigate(new Uri("ChosenPhotoPage.xaml", UriKind.Relative));
                    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(AppResources.Exception + ex.Message);
                    return;
                }
    
                base.OnNavigatedTo(e);
            }
    Quote Originally Posted by SB Dev View Post
    This process works fine when choosing the first image but the issue appears when you try the second, third, etc. image?
    yes

    Quote Originally Posted by SB Dev View Post
    Can you post the code that you're using to create the stream, read the stream and apply the filter? Perhaps we can see some error there (e.g. buffer length limitation, etc.)
    Sure...

    In "ChosenPhotoPage.xaml, after I "pass" the stream of the photo:
    Code:
            protected async override void OnNavigatedTo(NavigationEventArgs e)
            {
     	        try
                {
                    App.Context.ChosenPhoto.Seek(0, SeekOrigin.Begin);
                    EditingSession filterSession = await EditingSessionFactory.CreateEditingSessionAsync(App.Context.ChosenPhoto);
    
                   // Apply the filter and decode into the bitmap.
                   filterSession.AddFilter(FilterFactory.CreateCartoonFilter(false));
                   await filterSession.RenderToImageAsync(Img, OutputOption.PreserveAspectRatio); //Img is an Image Control in the page
    
                    filterSession.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(AppResources.Exception + ex.Message);
                    return;
                }
    
                base.OnNavigatedTo(e);
            }

    Another information I can give you... Same photo is shown good or bad depending I'm showing it first time or not...
    Last edited by shinobi86; 2013-12-05 at 09:15.

  5. #5
    Registered User
    Join Date
    Mar 2013
    Posts
    8

    Re: Cutted image and back button

    Quote Originally Posted by yan_ View Post
    I 99% sure it's because WP display your picture before the rendering is finished. It's similar to this : http://developer.nokia.com/Community...her_correction

    (I thinks sdk use wavelet transformation.)

    In simple, add invalidate after rendering. A better solution is to create a new WriteableableBitmap when you make a new rendering and set as Image control source after the rendering.
    Ok, i'll try to invalidate it... otherwise, i'll try to use WriteableableBitmap too...

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    475

    Re: Cutted image and back button

    If you use RenderToImageAsync it's not normal to see this phenomena... Maybe a bug :/

    You could try a writeableBitmap to see if you have same phenomena.

    SDK have been update and EditingSession and RenderToImageAsync doesn't exist anymore. You should update you code with new SDK
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  7. #7
    Registered User
    Join Date
    Mar 2013
    Posts
    8

    Re: Cutted image and back button

    OMG... I simply hate to use obsolete methods.... ufff
    Now I also understand because I have seen code that was different from mine... but I think, the method is still available but perhaps it would not be used anymore!

    Do you have a link where I can see the implementation I should use please?

    Thnax

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    475

    Re: Cutted image and back button

    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  9. #9
    Registered User
    Join Date
    Mar 2013
    Posts
    8

    Re: Cutted image and back button

    Thanx!

    I have a problem... In the example is not explain how to apply a filter in a moment different from the instantiation (uff, difficult to write this word)...

    It look like that the only way to apply a filter is in this way:

    Code:
    filterEffects.Filters = new[] { new CartoonFilter(false) };
    I need a method like Add, Apply, ...

    Can you help me plz?

  10. #10
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    475

    Re: Cutted image and back button

    You can look this sample http://developer.nokia.com/Resources...-explorer.html

    To modify filter pipeline, yu can create a List<IFilter> ans use it to set filterEffects.Filters. List have Add,insert,remove ...
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  11. #11
    Registered User
    Join Date
    Mar 2013
    Posts
    22

    Re: Cutted image and back button

    Quote Originally Posted by shinobi86 View Post
    Thanx!

    I have a problem... In the example is not explain how to apply a filter in a moment different from the instantiation (uff, difficult to write this word)...

    It look like that the only way to apply a filter is in this way:

    Code:
    filterEffects.Filters = new[] { new CartoonFilter(false) };
    I need a method like Add, Apply, ...

    Can you help me plz?
    Hello shinobi86,

    If you want simple method like Add, Apply, Undo, take a look at my framework. This is what you want

Similar Threads

  1. how to fit image on button if image size is large than button
    By vikranttanwar@ in forum Mobile Java UI and User Experience
    Replies: 5
    Last Post: 2013-08-14, 00:34
  2. Replies: 3
    Last Post: 2011-10-31, 13:37
  3. Replies: 1
    Last Post: 2010-04-25, 23:03
  4. Back Button
    By ff123 in forum Symbian
    Replies: 26
    Last Post: 2009-10-06, 07:18
  5. Replies: 4
    Last Post: 2007-11-22, 11:11

Posting Permissions

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