我想使用适用于Windows Phone 7.5的silverlight将图像分成几个较小的图像。
首先,我想知道这是否有可能(最近我对Windows Phone API感到不愉快),如果可以,请给我一些示例,因为我完全找不到。
谢谢您的帮助。
最佳答案
WriteableBitmapEx与Windows Phone兼容,并且具有Crop
方法来实现此目的。您只需要进行数学运算即可确定要裁剪的宽/高和X / Y坐标。
//this creates the four quadrants of sourceBitmap as new bitmaps
int halfWidth = sourceBitmap.PixelWidth / 2;
int halfHeight = sourceBitmap.PixelHeight / 2;
WriteableBitmap topLeft = sourceBitmap.Crop(0, 0, halfWidth, halfHeight);
WriteableBitmap topRight = sourceBitmap.Crop(halfWidth, 0, halfWidth, halfHeight);
WriteableBitmap bottomLeft = sourceBitmap.Crop(0, halfHeight, halfWidth, halfHeight);
WriteableBitmap bottomRight = sourceBitmap.Crop(halfWidth, halfHeight, halfWidth, halfHeight);
在上面的示例中,我可能没有经过一个像素(未测试),但是它应该演示API。
关于c# - 将图像分成几块Silverlight Windows Phone,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11108661/