1

I want to display a picture in a canevas. The canevas is smaller than the picture and I want the picture to be scaled and centered like in the exemple below.

I can't use Stretch=UniformToFill because it crop the part of the picture which are not in the frame (the green parts in exemple) and I need to be able to move the picture. (By moving the picture, the user can select the part of the picture he want to keep). It's also why, I can't use renderTransform.

I try to scale and translate my picture programmatically. I have implemented a pinch to zoom based on this post and now I want to use the CompositeTransform item to do my tranformations.

The scale work but not the translation. Whatever is the scale factor set, nothing change.

What I have with a Stretch=none:

What I have

What I want to get programmaticaly :

What I need

Here is my code :

double scaleFactor = (CanvasCropPola.ActualHeight) / Math.Min(ImageCropPola.ActualHeight, ImageCropPola.ActualWidth);
double transX = 500; // regardless of this value, the translation don't work

myCompositeTransfrom.ScaleX = scaleFactor; // work
myCompositeTransfrom.ScaleY = scaleFactor; // work
myCompositeTransfrom.TranslateX = transX; // don't work :'(
Community
  • 1
  • 1
Morniak
  • 958
  • 1
  • 12
  • 37
  • Have you tried using the [Nokia Imaging SDK](http://visuallylocated.com/post/2014/01/27/Crop-and-resize-any-image-to-create-a-lockscreen-for-your-phone-with-the-RTM-Nokia-Imaging-SDK.aspx)? – Shawn Kendrot Apr 25 '14 at 15:24
  • I've not tried but I don't like the idea of using an SDK for a realy simple task like that. I'm sure it's possible to do that with the native tools and I prefer to find my mistake that use an alternative solution. But if I stay blocked for a long time, I will take a look to this SDK. Thanks for the link ! – Morniak Apr 25 '14 at 15:54

0 Answers0