将网格另存为字节

时间:2012-04-25 14:18:52

标签: silverlight silverlight-4.0 silverlight-3.0 silverlight-toolkit silverlight-5.0

我想开发像ms paint这样的Silverlight项目。我找到了一个例子。但它有一个问题。我无法将DrawingArea网格保存为图像文件或字节。我不知道如何将DrawingArea网格保存为字节。请帮助我

            <UserControl
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="SilverlightPaintApplication.MainPage" 
            Width="805" Height="600" mc:Ignorable="d" BorderThickness="0,0,0,0" BorderBrush="{x:Null}">
            <Grid x:Name="LayoutRoot" Background="#FFFFFFFF" Width="Auto" >

                ...

            <Grid x:Name="DrawingArea" Margin="0,0,-5,8" MouseMove="DrawingArea_MouseMove" MouseLeftButtonDown="DrawingArea_MouseLeftButtonDown" MouseLeftButtonUp="DrawingArea_MouseLeftButtonUp" Background="#FFFFFFFF"/>

                ...

            </Grid>
        </UserControl>

1 个答案:

答案 0 :(得分:2)

我认为解决方案是使用Writeable Bitmap并将其保存为as explained here