title: UWP: Get exact position of mouse (pointer) click inside image
body: <p>I have a ContentDialog where I have an image and another image overlayed to place a watermark on it:</p>
  <pre><code>    &lt;StackPanel Orientation=&quot;Vertical&quot;&gt;
          &lt;Grid&gt;
              &lt;Image x:Name=&quot;ImageOriginal&quot; Source=&quot;{x:Bind OriginalImage, Mode=OneWay}&quot; MinHeight=&quot;120&quot; MinWidth=&quot;160&quot;/&gt;
              &lt;Image x:Name=&quot;ImageOverlay&quot; Source=&quot;{x:Bind OverlayImage, Mode=OneWay}&quot; MinHeight=&quot;120&quot; MinWidth=&quot;160&quot; PointerPressed=&quot;ImageOverlay_PointerPressed&quot; /&gt;
          &lt;/Grid&gt;
          ...
  </code></pre>
  <p>So the goal was, to place a text (centered horizontally and vertically) on the clicked position.</p>
  <pre><code>        private void ImageOverlay_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
          {
              e.Handled = true;
  
              var point = e.GetCurrentPoint(ImageOverlay);
              var pointPosition = new Windows.Foundation.Point((int)point.Position.X, (int)point.Position.Y);
              Position = new PointF((float)pointPosition.X, (float)pointPosition.Y);
  
              UpdateOverlayImage();
          }
  </code></pre>
  <p>(PointF) is a floating point point of ImageSharp. With the code above my text placement is always a bit off, like 50 pixels in each direction.</p>
  <p>I also tried it with the following code, but this just makes the text placed wrongly in the opposite direction:</p>
  <pre><code>            GeneralTransform transform = ImageOverlay.TransformToVisual(Window.Current.Content);
              Windows.Foundation.Point coordinatePointToWindow = transform.TransformPoint(pointPosition);
  </code></pre>
  <p><em>Update:</em></p>
  <p>Someone wanted to know, how I draw the text,s o here it is, this code is inside <code>UpdateOverlayImage()</code>:</p>
  <pre><code>        var watermarkedImage = OverlayImageBase.Clone(ctx =&gt; ctx.ApplyWatermark(font, tbWatermarkText.Text, color, Position));
          OverlayImage = watermarkedImage.ToBitmap();
  </code></pre>
  <p>And the <code>ApplyWatermark</code> extension method looks like this:</p>
  <pre><code>        public static IImageProcessingContext ApplyWatermark(this IImageProcessingContext processingContext,
              Font font,
              string text,
              Color color,
              PointF position)
          {
              var textGraphicOptions = new TextGraphicsOptions(true)
              {
                  ColorBlendingMode = SixLabors.ImageSharp.PixelFormats.PixelColorBlendingMode.Normal,
                  HorizontalAlignment = SixLabors.Fonts.HorizontalAlignment.Center,
                  VerticalAlignment = SixLabors.Fonts.VerticalAlignment.Center,
              };
              return processingContext.DrawText(textGraphicOptions, text, font, color, position);
          }
  </code></pre>
  <p>Any ideas why my coordinates are off?</p>