我正在尝试将图像数据转换为流以获取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
呢?
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);
}
}
您是否尝试使用WriteableBitmap
将Image
转换为stream
?
位图源到流 Windows Phone