我在微软的Windows 8应用程序上遇到了这个针对图像裁剪的解决方案,但我需要强制用户裁剪到特定比例(例如1:1,4:3),请建议/或任何有更好的解决方案吗?
非常感谢你。
这是解决方案(该解决方案允许用户在x,y上自由裁剪) http://code.msdn.microsoft.com/windowsapps/CSWin8AppCropBitmap-52fa1ad7/sourcecode?fileId=70609&pathId=1727496808
http://code.msdn.microsoft.com/windowsapps/CSWin8AppCropBitmap-52fa1ad7
/// <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;
}