Rotate an image according orientation sensors

Hello Everybody !!
I need to rotate an image according orientation sensors.
In fact, I need when the user rotate the device to the left, the image rotate to the left (like an arrow in GPS).
This is my XAML Code : 
<Canvas Canvas.ZIndex="1"
>
<StackPanel Margin="140,385,0,0">
<Image Source="ms-appx:///Assets/Icons/[email protected]"
Height="50"
x:Name="ArrowFontaine" />
</StackPanel>
</Canvas>
And my C# Code : 
private Compass _compass; // Our app's compass object
// This event handler writes the current compass reading to
// the textblocks on the app's main page.
private async void ReadingChanged(object sender, CompassReadingChangedEventArgs e)
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
CompassReading reading = e.Reading;
var image = new Image
Height = 50,
Width = 50,
RenderTransform = new RotateTransform()
Angle = 45,
CenterX = reading.HeadingMagneticNorth,
CenterY = (double)reading.HeadingTrueNorth,
Source = new BitmapImage(new Uri("ms-appx:///Assets/Icons/[email protected]"))
ArrowFontaine=image;
public MainPage()
this.InitializeComponent();
_compass = Compass.GetDefault(); // Get the default compass object
// Assign an event handler for the compass reading-changed event
if (_compass != null)
// Establish the report interval for all scenarios
uint minReportInterval = _compass.MinimumReportInterval;
uint reportInterval = minReportInterval > 16 ? minReportInterval : 16;
_compass.ReportInterval = reportInterval;
_compass.ReadingChanged += new TypedEventHandler<Compass, CompassReadingChangedEventArgs>(ReadingChanged);
I need the "ArrowFontaine" rotate according the device rotation to an angle of 45°.
Can you tell me where the error in my code please?
Please do not send me msdn link because most of my code from there
Thanx

Hi DiddyRennes,
>>In fact, I need when the user rotate the device to the left, the image rotate to the left (like an arrow in GPS).
I would suggest you creating RotateTransform in xaml and change the Angle from code behind:
<Canvas>
<StackPanel Canvas.Left="145" Canvas.Top="86">
<Image Source="ms-appx:///Assets/Avatar.png"
Height="100"
x:Name="ArrowFontaine" RenderTransformOrigin="0.5,0.5" >
<Image.RenderTransform>
<RotateTransform x:Name="rotateTransform1" Angle="0" CenterX="0.5" CenterY="0.5"/>
</Image.RenderTransform>
</Image>
<Button Content="Action" Click="Button_Click" />
</StackPanel>
</Canvas>
private async void ReadingChanged(object sender, CompassReadingChangedEventArgs e)
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
CompassReading reading = e.Reading;
rotateTransform1.Angle = reading.HeadingMagneticNorth;//Change something here
Screenshot:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • My rotation orientation sensor not working.

    I am using iphone5 and I tried everything for the rotation even I showed it to istore engineers, they say my iPhone is perfectly alright, no software neither hardware issues. But still my iPhone does not rotate I don't know why. Photos, videos and even some of games. I think there is some problem with orientation sensor, but even the engineers cannot figure it out. Can someone please please help me out with this problem.

    Did you try a reset?
    Restart / Reset
    http://support.apple.com/kb/HT1430

  • Photoshop and Bridge CS5 does not auto rotate SOME images.

    Photoshop and Bridge CS5 does not rotate SOME of my vertical images.  Most other photos taken in the same time frame and with the same camera display perfectly.
    Orientation is checked for display under Preferences, Metadata, Camera Data. 
    There also seems to be a discrepancy how Orientation is described under Metadata for those images which DO auto rotate : sometimes it is -90 (which is how I hold the camera for verticals and which displays on most verticals) and sometimes it is "normal" even when it has auto rotated the image.   I do not understand this difference.
    "Normal" is also used to describe the orientation of those images which DO NOT auto rotate for viewing.
    The photos in questions were taken using a Nikon D-300 which is programmed to indicate the orientation of the camera and has always been programmed to do so. 
    I know I can manually change the orientation but we are talking about hundreds of images (I have over 10,000 photos in all; most of which display fine).
    What should I be looking for to explain and correct this issue?
    I appreciate anything you can do to help.  Thank you.

    Thanks for responding to my query.  I'll check out the thumbnail size.
    It is just so curious that 90% of the verticals auto rotate and the rest do not.  The ones that do not rotate are even from different years (other images in those years work fine), although all taken with the same camera.

  • How to rotate an image/text box by degrees in Pages?

    I think pages can do this, but I just can't find out how to make it works.
    How do you rotate an image or text box by whatever degrees and orientation you like?
    Thanks!

    Welcome to Apple Discussions
    Here's a picture (link above).

  • Rotate both image and a panel drawan on it

    Hi all,
    I need to perform this task:
    1. Display an image on the screen
    2. Position a Jpanel on the image
    3. Rotate the Image with the help of mouse
    4. JPanel should be rotated accordingly.
    I need help regarding the classes to use to perform it.
    Thanks in advance,

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class SpinningContext extends JPanel {
        BufferedImage image;
        double theta = 0;
        SpinningContext(BufferedImage image) {
            this.image = image;
            setLayout(null);
            JPanel panel = new JPanel();
            panel.setBackground(Color.red);
            Dimension d = getPreferredSize();
            int w = 40;
            int h = 50;
            int x = (d.width - w)/2;
            int y = (d.height - h)/2;
            panel.setBounds(x, y, w, h);
            add(panel);
        protected void paintComponent(Graphics g) {
            int w = getWidth();
            int h = getHeight();
            int x = (w - image.getWidth())/2;
            int y = (h - image.getHeight())/2;
            g.drawImage(image, x, y, this);
        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            Rectangle r = getBounds();
            g2.setColor(getBackground());
            g2.fill(r);
            double x = r.getCenterX();
            double y = r.getCenterY();
            AffineTransform at = AffineTransform.getRotateInstance(theta, x, y);
            g2.setTransform(at);
            super.paint(g);
        public Dimension getPreferredSize() {
            return new Dimension(400,400);
        public void setTheta(double theta) {
            this.theta = theta;
            repaint();
        public static void main(String[] args) throws IOException {
            String path = "images/geek/geek----t.gif";
            BufferedImage image = ImageIO.read(new File(path));
            SpinningContext test = new SpinningContext(image);
            ContextSpinner spinner = new ContextSpinner(test);
            test.addMouseListener(spinner);
            test.addMouseMotionListener(spinner);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test);
            f.pack();
            f.setLocation(200,200);
            f.setVisible(true);
    class ContextSpinner extends MouseInputAdapter {
         SpinningContext component;
         Point2D.Double center = new Point2D.Double();
         boolean dragging = false;
         double theta;
        ContextSpinner(SpinningContext sc) {
            component = sc;
        public void mousePressed(MouseEvent e) {
            Rectangle r = component.getBounds();
            center.setLocation(r.getCenterX(), r.getCenterY());
            theta = getTheta(e.getPoint());
            dragging = true;
        public void mouseReleased(MouseEvent e) {
            dragging = false;
        public void mouseDragged(MouseEvent e) {
            if(dragging)
                component.setTheta(getTheta(e.getPoint())-theta);
        private double getTheta(Point p) {
            double dy = p.y - center.y;
            double dx = p.x - center.x;
            return Math.atan2(dy, dx);
    }Image from:
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html

  • When I create a calendar, in iphoto 8, I had an information pane lower left corner with date and time of the picture. Can it possibly be that the iphoto developers forgot about that in iphoto 9? This was very helpful when placing images according to date.

    Today I updated to the latest iphoto version. The update itself went smooth and nice as one is used to from Apple. But when I wanted to finish my already started calendar, I have encountered two problems. The first is that I can't view the aperture library anymore directly from iphoto. Instead I have to open the iphtoto library in aperture but then my calendar isn't there. So now I have to copy images back and forth. No problem.
    However, the old iphoto had a small information area in the lower left corner which was very nice to place images on an exact date. This seems to be gone...?? Really? How am I supposed to sort images according to date and time when I have to back to the library view every time? That's not very convenient..Or am I missing something?
    Thanks for ANY help!
    Patrick

    The first is that I can't view the aperture library anymore directly from iphoto.
    THat is exceeding strange since iPhoto '08 could not open or share an Aperture library - that ability was first introduced in iPhoto '11 - with the latest version of iPhoto and or Aperture you can open the same library with either application - http://support.apple.com/kb/HT5043
    In the current version of iPhoto the photos are sorted by date in the film strip - I've not recently done a calendar so do not remember the specifics -
    LN

  • Although all photos in my libraries are rotated to the correct orientation, random pictures still show up in the wrong position when viewed on Apple TV. Any suggestions?

    Although all photos in my libraries are rotated to the correct orientation, random pictures still show up in the wrong position when viewed on Apple TV.
    Any suggestions?

    silvergc
    Thanks for your comments
    Several of our iPhone users in the UK reported the problem this morning, and as the Apple fan in the office I've got the job of resolving the issue
    The original Excel was an old .xls file, but I have saved it as a .xlsx and the problem still appears
    I haven't spoken with our developer yet, but I assume he has created the Excel file using some programming tools rather that directly using Excel
    In the meantime I have created a simply spreadsheet with 8 cells contain values
    In the first 4 cells, I have formatted them using Currency, and have used the currencies USD, DEM, GBP and CHF
    In the remaining cells I have formatted them using the Accounting option, using the same currencies
    When I review the spreadsheet on the iPhone (or iPad), the first 4 remain the same yet the last four all show the £ symbol
    I have now changed the Region Format of the iPhone to United States, and when viewing on the iPhone the bottom 4 values are now all showing the $ sign!
    If I had created the spreadsheet I would have put the Currency code in a seperate cell and purely used a numeric format for the number, and there would be no issue.  That might be the only solution
    Yes, the Director has the full MS Excel app on his Windows 8 device, but I can't expect all of our clients to go and do the same, in business many of them will have the iPhone
    We may have to change the way we produce the report because of Apple's failings here, and it's not the first time that we have had to change something because Apple devices can't display them properly
    In business, submitting a potential job contract only for the recipient to get the wrong idea of the costs is a major concern

  • How do i rotate an image in keynote?

    Im trying to rotate an image in keynote bc im making a collage and i dont want all my images straight up and down. Does anyone know how to do that?

    Nevermind i figured it out =)

  • Portrait Mode Lock / Orientation Sensor

    If anyone from Apple is reading this, I have a suggestion for improving the iPhone user interface.
    My wife and I are relatively new to our iPhones.  I frequently use the orientation sensor for photos, safari, email and other apps so that I can switch the display from landscape to portrait mode by tilting the phone to the appropriate orientation.  My wife saw me doing this and noted that her iPhone, identical to mine (4s) doesn't do that, and indeed, on examining it, it didn't.  I carefully went through the Settings dialog and the Settings|General dialog and any promising looking page below these and found nothing.  I assumed that the orientation sensor was broken, and we called up Verizon, from whom we bought our phones.
    The (very helpful!) tech person at our local Verizon store had to look this one up, and it took him some time, but he finally located a software switch, accessible by double-tapping the home button - a "Portrait Mode Lock".
    This is an OK location for such a control, along with a general volume control, but this switch should also be available from the Settings menu, along with brightness and other hardware-specific switches.  This is, after all a "hardware setting" and the Settings page is the logical place to look for it.  I would strongly suggest that whether or not this switch is left on the Phone Favorites line, it should be available from somewhere in the Settings page heirarchy.

    No one from Apple is reading this forum, its just a user forum like you and I.
    You can send them a feedback here:
    http://www.apple.com/feedback/

  • My video was recorded on my I phone 4, the camera was held sideways for a horizontal view, but loads in I movie vertically.  How can I rotate the image so it is horizontal?

    My video was recorded on my I phone 4, the camera was held sideways for a horizontal view, but loads in I movie vertically.  How can I rotate the image so it is horizontal?

    Drag the clip from your Event to your Project. Then use the Rotate, Crop, Ken Burns Tool on the Middle Toolbar to rotate it

  • Partial rotation of images when importing...

    I'm wondering how to stop Lightroom from "squaring up" my images when I import them.  Attached is a screen shot to illustrate.
    I also can't find any consistentency, if I import the same image three times it will be as above twice but not on the third time!
    I'm wondering if this is a metadata thing?
    BTW camera is a Nikon D600.
    With thanks in advance,
    -Simon

    If this is only happening to a few of the images on import it is most likely something related to your camera. If ALL of the Imported images exhibit the issue then there are two things in LR that could cause this to happen:
    1) You are applying a Develop preset on Import that has  Lens Corrections> Manual> Rotate tool setting other than '0.'
    2) Your LR 'Default Develop Settings' has a Crop Angle tool or Lens Corrections> Manual> Rotate tool setting other than '0.'
    To check this import one of the images from CF card that shows the rotation. Examine the Crop Angle tool and Lens Corrections> Manual> Rotate tool settings to determine which one is being applied. From inside the Develop module with the imported image still rotated hit the master 'Reset' button at the bottom of the right-hand Develop panel. This applies your LR 'Default Develop Settings.'
    a) If the image is still rotated you may have inadvertently updated your LR 'Default Develop Settings' in the past with the image rotated. To correct this simply hit the master 'Reset' button, reset both the Crop Angle tool and Manual Rotate tools to '0,' go to toolbar Develop> Set Default settings, and select 'Update to Current Settings.'
    b) If the image is not rotated you are probably applying a Develop preset that was inadvertently created with the image rotated. You will need to recreate this preset making sure Lens Corrections> 'Transform' is unchecked. This is the only Develop preset setting that will rotate the image as in your example.
    If neither a or b fixes the issue you can try resetting your LR Preferences file:
    http://members.lightroomqueen.com/Knowledgebase/Article/View/1148/198/how-do-i-delete-the- lightroom-preferences-file

  • Can anyone help me to add method to rotate the image using mouse?

    Hi everyone, i am currently creating a game which require the user to be able to drag and rotate the image
    on the screen..but sadly...i'm only able to do the dragging part..
    Can anyone be able to help me add the method to rotate the image using the mouse?
    Thanks :-)
    the code
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    class Game extends JFrame {
         DisplayCanvas canvas;
         public Game() {
              super("My Game");
              Container container = getContentPane();
              canvas = new DisplayCanvas();
              TitledBorder border = new TitledBorder("Game Window");
              border.setTitlePosition(TitledBorder.BOTTOM);
              canvas.setBorder(border);
              container.add(canvas);
              addWindowListener(new WindowEventHandler());
              setSize(450,400);
              show();
              class WindowEventHandler extends WindowAdapter {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              public static void main(String arg[]) {
                   new Example();
         class DisplayCanvas extends JPanel {
              int x, y;
              BufferedImage bi;
              DisplayCanvas() {
                   setBackground(Color.white);
                   setSize(450,400);
                   addMouseMotionListener(new MouseMotionHandler());
                   Image image = getToolkit().getImage("duke.gif");
                   MediaTracker mt = new MediaTracker(this);
                   mt.addImage(image, 1);
                   try {
                        mt.waitForAll();
                   catch (Exception e) {
                        System.out.println("Exception while loading image.");
                   if (image.getWidth(this) == -1) {
                        System.out.println("***Make sure you have the image "
                        + "(duke.gif) file in the same directory.*****");
                        System.exit(0);
                   bi = new BufferedImage(image.getWidth(this),
                   image.getHeight(this),
                   BufferedImage.TYPE_INT_ARGB);
                   Graphics2D big =bi.createGraphics();
                   big.drawImage(image, 0, 0, this);
              public void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   Graphics2D g2D = (Graphics2D) g;
                   g2D.drawImage(bi, x, y, this);
              class MouseMotionHandler extends MouseMotionAdapter {
                   public void mouseDragged(MouseEvent e) {
                        x = e.getX(); y = e.getY();
                        repaint();

    research a bit on AffineTransforms. you can set the rotated instance of the Graphics2D class and it will do the rotations for you :-D

  • Rotating an image and getting back the image...

    Hi,
    I have a small problem using images...
    1. I have an existing image...
    2. I need to rotate the image by a certain angle(say 60 degree)....
    3. Return the rotated image back to the calling routine...
    My problem is that I can rotate the image using the AffineTransform, and draw the image immediately... but I cannot return the rotated image... can anyone help me out on this??????

    No sorry that didn't fix it. I forgot to mention that I already have a method in ImagePanel called clearImage()
         * Clear the image on this panel.
        public void clearImage()
            if(panelImage != null) {
                Graphics imageGraphics = panelImage.getGraphics();
                imageGraphics.setColor(Color.LIGHT_GRAY);
                imageGraphics.fillRect(0, 0, width, height);
                repaint();
        }But if I clear the panel and then try to apply the function nothing happens. The LIGHT_GRAY background remains.
    This is how I apply a function in the class[b] ImageViewer
         * Apply a given function to the current image
        private void applyFunction(Function function)
             if(currentImage != null) {     
                  if(function.getName().equals("Zoom In")) {
                       Zoom.ZOOMIN_RATE = 1.5;
                       function.apply(currentImage);
                  else if(function.getName().equals("Zoom Out")) {
                       Zoom.ZOOMIN_RATE = 0.5;
                       function.apply(currentImage);
                  else {          
                       imagePanel.clearImage();
                       function.apply(currentImage);    //A function is applied                   
                  frame.repaint();              
                  showStatus("Applied: " + function.getName());
             else {
                  showStatus("No image loaded.");
        }

  • Unable to rotate raw images in bridge, rotate buttons grayed out?

    Unable to rotate raw images in bridge, rotate buttons grayed out? 
    Bridge 5.0.2.4. 

    There is an ignore EXIF setting Preferences. I can't remember if that is Bridge or Photoshop, but IIRC it is for DNG files.
    Right.  Check Photosho > Preferences > File handling and make sure 'Ignore EXIF tag, is not checked.  I think that might do it, so long as it refers to sidecare files, because only RAW files would have one.

  • Rotating Multiple Images in Fireworks

    I have my home page designed in Fireworks MX 2004. I'd like
    to set a rotation of images (all same size) into my page. Can I do
    this in Fireworks?
    Previously I used a Java script from another source but after
    adding swap image behavior to my menu text my rotation script no
    longer works. I don't know Java well so I'm assuming the two
    scripts are stepping on each other toes somehow.
    Thank you for any input you may have,
    Tim

    Hi Tim,
    Unless you create a GIF animation with the images (not
    recommended for
    photos) you can't do this in Fireworks.
    Linda Rathgeber [PVII] *Adobe Community Expert-Fireworks*
    http://www.projectseven.com
    Fireworks Newsgroup:
    news://forums.projectseven.com/fireworks/
    CSS Newsgroup: news://forums.projectseven.com/css/
    Design Aid Kits:
    http://www.webdevbiz.com/pwf/index.cfm

Maybe you are looking for

  • Error when opening indd-file: Either the file does not exist, you do not have permission, or the...

    Hi! I'm having trouble opening a indd-file. It was sent to me as a zip-fil along with the used fonts and links. When I try to open the file, I'm getting this error: "Either the file does not exist, you do not have permission, or the file may be in us

  • Unable read container element in the BO

    Hi I have created a new container element in the task and trying to pass the value and read the same value in the bussiness object method using the statement   "SWC_GET_ELEMENT CONTAINER 'Classification' l_KLGRU1". I have created the the container el

  • Computer freezes while updating security.

    Hello again. My computer's problems have only intensified. Originally my computer would only freeze while multi-tasking or under heavy graphic stress. Now, the computer freezes while preforming mundane tasks such as moving a window. It's branched int

  • IMac HDMI 'Mirroring' problems with LG 'Full HD' TV

    I have my 20" aluminium iMac connected via a mini-DVI/HDMI adapter to my LG 32LF7700 full HD LCD TV. In mirroring mode it's pretty good, but I have two problems. 1. Even when I turn 'Mirroring' off from my Mac's displays 'Menu' options I still have t

  • Aperture on MacBook Pro

    I have a MacBook Pro with a 2.0 GHz Intel Core Duo processor. It has 1.5 gigs of RAM. Since the recommended RAM is 2.0 I was wondering if anyone knew if Aperture 2.0 will run o.k. on it? Or will be frustratingly slow? Any advice would be much appreci