簡體   English   中英

WP8空白圖像被保存到庫中

[英]WP8 Blank image being saved to Library

我正在嘗試將圖像保存到手機的照片庫中。 這是XAML標記。

<Canvas x:Name="canMeme" HorizontalAlignment="Left" Height="400" Margin="26,134,0,0" VerticalAlignment="Top" Width="400">
    <Image x:Name="imgMeme" Height="400" Width="400"/>
    <TextBlock x:Name="topText" Width="400" TextWrapping="Wrap" HorizontalAlignment="Center" FontWeight="Bold" TextAlignment="Center" Text="Am i the only one around here" FontSize="40" Foreground="White"/>
    <TextBlock x:Name="bottomText" TextWrapping="Wrap" Text="TextBlock" Canvas.Top="372" Width="400" HorizontalAlignment="Center" TextAlignment="Center" FontWeight="Bold" Height="28" Margin="0,0,0,20" />
</Canvas>

我正在嘗試將“畫布”保存到圖像中。 將在運行時為文本框以及圖像提供值。 這是我要做的代碼:

try
{

    using (MemoryStream ms = new MemoryStream())
    {
        Extensions.SaveJpeg(imagebitmap, ms, imagebitmap.PixelWidth, imagebitmap.PixelHeight,0,100);
        ms.Seek(0, SeekOrigin.Begin);
        library.SavePicture(string.Format("Images\\{0}.jpg", name.ToString()), ms);
    }
    MessageBox.Show(string.Format("Image has been saved as {0}", name.ToString()));
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString());
}

該代碼運行,但隨后似乎會生成一個空圖像。 有什么我想念的嗎?

您忘記了將XAML與實際位圖綁定。

您可以閱讀有關MSDN上綁定的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM