【发布时间】:2014-02-08 11:54:39
【问题描述】:
如何将 Convert Bitmap 转换为 Byte Array 并保存到 Sqlite。我正在使用 c# 和 xaml
这是我的代码
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”类型的第一个参数' 可以找到(您是否缺少 using 指令或程序集引用?)
图像格式错误:
The name 'ImageFormat' does not exist in the current context
【问题讨论】:
-
您从哪里找到表明
BitmapSource有Save方法的信息,您从哪里了解到ImageFormat? -
WPF image to byte array 的可能重复项。好吧,实际上那里只回答了第一个问题,但这似乎就是您所需要的,因为您根本没有在帖子中询问 SQLite。