C# 将位图转换为字节数组并保存到Sqlite

C# 将位图转换为字节数组并保存到Sqlite,c#,sqlite,bitmap,C#,Sqlite,Bitmap,如何将位图转换为字节数组并将其保存到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.Pixe

如何将位图转换为字节数组并将其保存到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指令或程序集引用?)

ImageFormat错误:

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

一种方法可能是将位图图像转换为普通位图,然后保存该流

见:


希望这对您有所帮助

您在哪里找到了表明
BitmapSource
具有
Save
方法的信息,以及您从哪里了解到的
ImageFormat
?的可能重复。实际上,这里只回答了第一个问题,但这似乎是您所需要的,因为您根本没有在帖子中询问SQLite。