UIElement 到图像文件 (WP7)
我有一个 StackPanel,其中包含一些我想要放入图像文件(例如 PNG)的矩形。我正在 Windows Phone 7 上开发此程序,我在互联网上找到的大部分信息(我认为)不适用于 WP7。
我认为 System.Windows.Media.Imaging 命名空间是关键,但我不知道从哪里开始。
这基本上就是我想要做的:
StackPanel stack = new StackPanel();
List<Rectangle> recList = new List<Rectangle>();
向 recList
添加一些矩形
foreach(var x in recList)
stack.Children.Add(x);
,然后将 stackpanel 保存到图像文件...
I have a StackPanel
which includes a few Rectangles
that I want put to an image file (e.g. PNG). I'm developing this on Windows Phone 7 and most of the information I found on the internet wasn't applicable (I think) to WP7.
I think the System.Windows.Media.Imaging
namespace is the key to this, but I'm not sure where to begin.
This is basically what I want to do:
StackPanel stack = new StackPanel();
List<Rectangle> recList = new List<Rectangle>();
add some rectangles to recList
foreach(var x in recList)
stack.Children.Add(x);
then save the stackpanel to an image file...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
WriteableBitmap
来保存图像。您可以将
MemoryStream
更改为独立存储流。如果您想在图像控件中显示上述MemoryStream
:或者,保存到独立存储:
You can use a
WriteableBitmap
to save the image.You can change the
MemoryStream
to be an Isolated Storage stream instead. If you want to display the aboveMemoryStream
in an Image control:Or, saving to Isolated Storage: