首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将图像拆分为多个部分silverlight windows phone

将图像拆分为多个部分silverlight windows phone
EN

Stack Overflow用户
提问于 2012-06-20 04:13:41
回答 3查看 3.1K关注 0票数 2

我想使用windows phone 7.5版的silverlight将一个图像分割成几个较小的图像。

首先,我想知道这是否可能(我最近在windows phone APIs上遇到了一些令人不快的惊喜),如果是的话,请给我一些例子,因为我完全找不到。

谢谢你的帮助。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-06-20 04:34:35

WriteableBitmapEx与Windows Phone兼容,并且有一个Crop方法可以做到这一点。你只需要计算出裁剪的宽/高和X/Y坐标。

代码语言:javascript
运行
复制
//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。

票数 4
EN

Stack Overflow用户

发布于 2012-06-20 04:18:09

您可以将您的silverlight项目与XNA结合使用,并使用spritebatch.Draw()。它有一个源矩形的参数,可以让你从图像中绘制一个零件。

MSDN对如何结合silverlight和XNA有一些帮助。http://msdn.microsoft.com/en-us/library/hh202938(v=vs.92).aspx

票数 0
EN

Stack Overflow用户

发布于 2012-06-20 04:27:11

组合ScaleTransform和TranslateTransform以呈现正确的部分。

ScaleTransform (numXTiles,numYTiles)

翻译(xTileIndex / numXTiles,yTileIndex / numYTiles);

将ImageControl放在网格内以进行裁剪

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11108661

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档