2014-01-19 49 views
0

如何将转换位图转换为字节数组并将其保存到Sqlite。使用C#和XAML林将位图转换为字节数组并将其保存到Sqlite

这里是我的代码为 “保存”

BitmapSource image = new BitmapImage(new Uri("ms-appx:///Assets/BG.jpg", UriKind.Absolute)); 

using (MemoryStream ms = new MemoryStream()) 
{ 
    WriteableBitmap btmMap = new WriteableBitmap 
    (image.PixelWidth, image.PixelHeight); 

    // write an image into the stream 
    image.Save(ms, ImageFormat.Jpeg); // error, Save and ImageFormat 
} 

错误:

'Windows.UI.Xaml.Media.Imaging.BitmapSource' 不包含“保存的定义'并且没有扩展方法'保存'接受类型'Windows.UI.Xaml.Media.Imaging.BitmapSource'的第一个参数可能被发现(你是否缺少使用指令或程序集引用?)

ErrorFor ImageFormat :

The name 'ImageFormat' does not exist in the current context 
+1

你在哪里找到这表明'BitmapSource'有一个'Save'方法的信息,以及你在哪里了解'ImageFormat'? –

+0

[WPF图像到字节数组]的可能重复(http://stackoverflow.com/questions/553611/wpf-image-to-byte)。那么,实际上只有第一个问题在那里得到了答案,但这似乎是你所需要的,因为你根本没有在你的帖子中询问SQLite。 – Dirk

回答

相关问题