我想使用 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# - 将图像分割成几 block silverlight Windows Phone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11108661/