将一张图片分割成几张SilverlightWindowMobile我想用Silverlightforwindowsphone7.5将一张图片分割成几张小图。首先,我想知道这是否可行(最近我对WindowsPhoneAPI感到有些意外),如果可行,请给我一些示例,因为我一无所获。感谢您的帮助。WriteableBitmapEx与WindowsPhone兼容,并且有一个Crop方法可以做到这一点。您只需计算一下即可确定要裁剪的宽度/高度和X/Y坐标。//这将sourceBitmap的四个象限创建为新位图inthalfWidth=sourceBitmap.PixelWidth/2;inthalfHeight=sourceBitmap.PixelHeight/2;WriteableBitmaptopLeft=sourceBitmap.Crop(0,0,halfWidth,halfHeight);WriteableBitmaptopRight=sourceBitmap.Crop(halfWidth,0,halfWidth,halfHeight);WriteableBitmapbottomLeft=sourceBitmap.Crop(0,halfHeight,halfWidth,halfHeight);WriteableBitmapbottomRight=sourceBitmap.Crop(halfWidth,halfHeight,halfWidth,halfHeight);在上面的例子中,我可能被一个像素关闭了(没有测试它),但它应该演示了API。您可以将Silverlight项目与XNA一起使用并使用spritebatch.Draw()。它采用源矩形参数并从图像中绘制一部分。MSDN对如何结合silverlight和XNA有一些帮助。http://msdn.microsoft.com/en-us/library/hh202938(v=vs.92).aspx结合ScaleTransform和TranslateTransform渲染正确的部分。ScaleTransform(numXTiles,numYTiles)翻译(xTileIndex/numXTiles,yTileIndex/numYTiles);将ImageControl放入grid中进行裁剪以上就是C#学习教程:将图片分成若干个silverlight窗口手机分享的全部内容,如果你有用过需要详细了解C#学习教程。希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
