×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Question Rotate the viewfinder & Capture a portrait image in Windows Phone

    Hi,all

    I'm creating a camera app based on Silverlight/XNA framework as the yan_ 's example Use Camera with XNA, but in when the page oritation changed to the Portrait , the viewfinder of camera dose not shows correctly, the direction of viewfinder dose not rotate when the page oritation changed, and the captured picture is also in landscape layout(width > height),not portrait layout(height > width ).

    How could I rotate the viewfinder when the page oritation changed to portrait and capture a portrait layout picture.

    If you don't understand what I said, just check out this similarly post on MSDN forum:video recorder sample - viewfinder orientation issue

    Could anyone give me a hand, thanks in advance.

    Regards.
    Last edited by small2; 2012-08-14 at 03:26. Reason: Modify

  2. #2
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Hi

    Please check this post where your problem is solved

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    I had solved the second problem: capture a portrait layout picture.
    Here is the solution:http://timheuer.com/blog/archive/201...-rotation.aspx

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Hi, thanks for the reply, I had read the post before, and it was not fit for me. It was used in Silverlight Framework, not SL/XNA mixed framework. As the example by Yan, in Sl/XNA, he used the previewbuffer data comes from the camera to fill a texture, and render it on the screen. I also tried to change the oritation of the teture., but it dose not woks. And I had no idea yet.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Quote Originally Posted by izinin View Post
    Hi

    Please check this post where your problem is solved
    Hi, thanks for the reply, I had read the post before, and it was not fit for me. It was used in Silverlight Framework, not SL/XNA mixed framework. As the example by Yan, in Sl/XNA, he used the previewbuffer data comes from the camera to fill a texture, and render it on the screen. I also tried to change the oritation of the teture., but it dose not woks. And I had no idea yet.

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

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Quote Originally Posted by small2 View Post
    Hi, thanks for the reply, I had read the post before, and it was not fit for me. It was used in Silverlight Framework, not SL/XNA mixed framework. As the example by Yan, in Sl/XNA, he used the previewbuffer data comes from the camera to fill a texture, and render it on the screen. I also tried to change the oritation of the teture., but it dose not woks. And I had no idea yet.
    Hi.
    previewBuffer don't use orientation information. It's you which must manage it.
    To display , you only need add a rotation when you draw the texture.

    To save it, it's depend what you save.
    - If it's the previewBuffer, you must make the orientation. Look RotateStream in this article : http://timheuer.com/blog/archive/201...-rotation.aspx
    - You can render your scene to a RenderTarget2D.
    - You can take a picture to have a better texture.

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Quote Originally Posted by yan_ View Post
    Hi.
    previewBuffer don't use orientation information. It's you which must manage it.
    To display , you only need add a rotation when you draw the texture.

    To save it, it's depend what you save.
    - If it's the previewBuffer, you must make the orientation. Look RotateStream in this article : http://timheuer.com/blog/archive/201...-rotation.aspx
    - You can render your scene to a RenderTarget2D.
    - You can take a picture to have a better texture.
    Hi, I had solved the second problem yet.
    I tried to add a rotation when I draw the texture like this.

    Code:
    Microsoft.Xna.Framework.Rectangle rec2 = new Microsoft.Xna.Framework.Rectangle(0, 0, (int)ActualHeight, (int)ActualWidth - 90);
     _spriteBatch.Draw(_cameraTexture, rec2, null, Microsoft.Xna.Framework.Color.White, (float)Math.PI / 2, new Vector2(_cameraTexture.Width / 2, _cameraTexture.Height/2), SpriteEffects.None, 0);
    but the viewfinder showed like this:

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

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    your picture is not displayed...
    look example. You must set screen position of texture origin :

    Code:
    Vector2 origin = new Vector2(CameraTexture.Width / 2, CameraTexture.Height / 2); // texture  origin
    Vector2 screenpos = new Vector2(240, 400); // origin position on screen
    spriteBatch.Draw(CameraTexture, screenpos, null, Microsoft.Xna.Framework.Color.White, (float)Math.PI / 2,           origin, 1.0f, SpriteEffects.None, 0f);

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    30

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Quote Originally Posted by yan_ View Post
    your picture is not displayed...
    look example. You must set screen position of texture origin :

    Code:
    Vector2 origin = new Vector2(CameraTexture.Width / 2, CameraTexture.Height / 2); // texture  origin
    Vector2 screenpos = new Vector2(240, 400); // origin position on screen
    spriteBatch.Draw(CameraTexture, screenpos, null, Microsoft.Xna.Framework.Color.White, (float)Math.PI / 2,           origin, 1.0f, SpriteEffects.None, 0f);
    Wow, it works. Thanks very much! I had misunderstood your advices before! But it seems like I can't render and fill the fullscreen with the texture(640*480) . What a pity!
    Last edited by small2; 2012-08-15 at 09:24.

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

    Re: Rotate the viewfinder & Capture a portrait image in Windows Phone

    Quote Originally Posted by small2 View Post
    But it seems like I can't render and fill the fullscreen with the texture(640*480) . What a pity!
    why?
    Do you use app bar or systray?

Similar Threads

  1. how to capture screen on windows phone
    By csu_nj in forum Windows Phone General
    Replies: 7
    Last Post: 2012-02-09, 13:40
  2. HOW TO CAPTURE AN IMAGE ON PHONE AND PUT INTO A BUFFER.....
    By srinivasreddy501 in forum Mobile Java General
    Replies: 2
    Last Post: 2009-12-12, 07:13
  3. picture capture without viewfinder
    By fecxelmin in forum Symbian
    Replies: 2
    Last Post: 2009-12-04, 08:24
  4. Periodic Image capture with Nokia 6131 phone
    By amarsahu in forum Streaming and Video
    Replies: 1
    Last Post: 2009-06-05, 14:37
  5. Replies: 2
    Last Post: 2008-04-24, 12:26

Posting Permissions

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