c# - 将图像分割成几 block silverlight Windows Phone

标签 c# silverlight image windows-phone-7 split

我想使用 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/

相关文章:

c# - 正则表达式 c# 只有正数

c# wp7 可检查列表

visual-studio-2008 - 我可以在 Visual Studio 2008 中使用 silverlight 4.0 吗?

c++ - 如何在循环中以不同的名称保存 cv::imwrite

c# - 自定义授权中的 MVC 4.0 FormsAuthentication 和 AuthorizeAttribute

c# - 隐藏动态div标签,包含动态输入按钮

c# - 从客户端下载 Silverlight 文件

c# - 在 Silverlight 的 Canvas 上动态绘制图像

python - 霍夫圆检测AttributeError : 'NoneType' object has no attribute 'rint'

algorithm - 从照片/图像生成线条