我尝试将图片数据转换为流以获取ExifInfo /元数据
MediaLibrary library = new MediaLibrary();
Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]);
photoFromLibrary.GetImage();
仅返回ImageData
我需要在我的方法中使用它
public static void GetMetaData(Stream photo)
{
ExifLib.JpegInfo info = ExifLib.ExifReader.ReadJpeg(photo);
var img = new BitmapImage();
img.SetSource(photo);
App.MainViewModel.MetaDate = ReadExif(info);
}
ExifLib.ExifReader.ReadJpeg(photo);
需要一个流
所以我从photoFromLibrary.GetImage();
获得的是ImageData
,但我需要stream
。那么如何将ImageData
转换为stream
?
答案 0 :(得分:0)
I hope your are looking for this result.
var wb = new WriteableBitmap(ContentPanel, new TranslateTransform());
using (var mediaLibrary = new MediaLibrary())
{
using (var stream = new MemoryStream())
{
var fileName = string.Format("{0}.jpg", DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"));
wb.SaveJpeg(stream, wb.PixelWidth, wb.PixelHeight, 0, quality);
stream.Seek(0, SeekOrigin.Begin);
var picture = mediaLibrary.SavePicture(fileName, stream);
}
}
答案 1 :(得分:0)
您是否尝试使用WriteableBitmap
将Image
转换为stream
?