Windows 8应用商店应用程序:以固定比率裁剪图像
我在Windows 8应用程序上遇到了Microsoft提供的图像裁剪解决方案,但我需要的是强制用户裁剪到特定的比例(例如1:1、4:3),请建议/或提供更好的解决方案 事先非常感谢 这是解决方案(该解决方案允许用户在x,y上自由裁剪)Windows 8应用商店应用程序:以固定比率裁剪图像,windows,windows-8,Windows,Windows 8,我在Windows 8应用程序上遇到了Microsoft提供的图像裁剪解决方案,但我需要的是强制用户裁剪到特定的比例(例如1:1、4:3),请建议/或提供更好的解决方案 事先非常感谢 这是解决方案(该解决方案允许用户在x,y上自由裁剪) // ///如果角点捕捉到的指针移动,选择区域将更新。 /// void Corner_PointerMoved(对象发送方,PointerRoutedEventArgs e) { Windows.UI.Input.PointerPoint pt=e.
//
///如果角点捕捉到的指针移动,选择区域将更新。
///
void Corner_PointerMoved(对象发送方,PointerRoutedEventArgs e)
{
Windows.UI.Input.PointerPoint pt=e.GetCurrentPoint(此);
uint ptrId=pt.PointerId;
if(pointerPositionHistory.ContainsKey(ptrId)&&pointerPositionHistory[ptrId].HasValue)
{
点电流位置=点位置;
Point previousPosition=pointerPositionHistory[ptrId]。值;
双xUpdate=currentPosition.X—previousPosition.X;
双yUpdate=currentPosition.Y—previousPosition.Y;
this.selectedRegion.UpdateCorner((发送者作为ContentControl)。标记为string,xUpdate,yUpdate);
pointerPositionHistory[ptrId]=当前位置;
}
e、 已处理=正确;
}
/// <summary>
/// If a pointer which is captured by the corner moves,the select region will be updated.
/// </summary>
void Corner_PointerMoved(object sender, PointerRoutedEventArgs e)
{
Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this);
uint ptrId = pt.PointerId;
if (pointerPositionHistory.ContainsKey(ptrId) && pointerPositionHistory[ptrId].HasValue)
{
Point currentPosition = pt.Position;
Point previousPosition = pointerPositionHistory[ptrId].Value;
double xUpdate = currentPosition.X - previousPosition.X;
double yUpdate = currentPosition.Y - previousPosition.Y;
this.selectedRegion.UpdateCorner((sender as ContentControl).Tag as string, xUpdate, yUpdate);
pointerPositionHistory[ptrId] = currentPosition;
}
e.Handled = true;
}