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 [URL="http://www.developer.nokia.com/Community/Wiki/Use_Camera_with_XNA"]Use Camera with XNA[/URL], but in when the page oritation changed to the [B]Portrait[/B] , the viewfinder of camera dose not shows correctly,[B] the direction of viewfinder dose not rotate[/B] when the page oritation changed, and the captured picture is also in landscape layout(width > height),not [B]portrait layout(height > width ).[/B]
How could I [B]rotate the viewfinder when the page oritation changed to portrait[/B] and [B]capture a portrait layout picture[/B].
If you don't understand what I said, just check out this similarly post on MSDN forum:[URL="http://social.msdn.microsoft.com/forums/en-us/wpdevelop/thread/6284db78-413f-463c-89ca-8e94d281b3cc"]video recorder sample - viewfinder orientation issue[/URL]
Could anyone give me a hand, thanks in advance.
Regards.
Re: Rotate the viewfinder & Capture a portrait image in Windows Phone
Hi
Please [URL="http://stackoverflow.com/questions/6612562/viewfinder-orientation-with-windows-phone-7-mango-photocamera"]check this post[/URL] where your problem is solved
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:[url]http://timheuer.com/blog/archive/2010/09/23/working-with-pictures-in-camera-tasks-in-windows-phone-7-orientation-rotation.aspx[/url]
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.
Re: Rotate the viewfinder & Capture a portrait image in Windows Phone
[QUOTE=izinin;901539]Hi
Please [URL="http://stackoverflow.com/questions/6612562/viewfinder-orientation-with-windows-phone-7-mango-photocamera"]check this post[/URL] where your problem is solved[/QUOTE]
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.
Re: Rotate the viewfinder & Capture a portrait image in Windows Phone
[QUOTE=small2;901544]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.[/QUOTE]
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 : [url]http://timheuer.com/blog/archive/2010/09/23/working-with-pictures-in-camera-tasks-in-windows-phone-7-orientation-rotation.aspx[/url]
- You can render your scene to a RenderTarget2D.
- You can take a picture to have a better texture.
Re: Rotate the viewfinder & Capture a portrait image in Windows Phone
[CODE][/CODE][QUOTE=yan_;901555]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 : [url]http://timheuer.com/blog/archive/2010/09/23/working-with-pictures-in-camera-tasks-in-windows-phone-7-orientation-rotation.aspx[/url]
- You can render your scene to a RenderTarget2D.
- You can take a picture to have a better texture.[/QUOTE]
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);
[/CODE]
but the viewfinder showed like this:[IMG]https://dt4mfa.bay.livefilestore.com/y1pSdGcJpioxrYxLFIYMBCovwyviQ8ibuKyEtN-Ii1hDft6hmSDknxo3C0N_v1faKJ7tRSDEPKEgliJcDrWz64fEPiDJrOE6a9H/WP_000082.jpg[/IMG]
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);[/CODE]
Re: Rotate the viewfinder & Capture a portrait image in Windows Phone
[QUOTE=yan_;901593]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);[/CODE][/QUOTE]
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!
Re: Rotate the viewfinder & Capture a portrait image in Windows Phone
[QUOTE=small2;901615]But it seems like I can't render and fill the fullscreen with the texture(640*480) . What a pity![/QUOTE]
why?
Do you use app bar or systray?