【发布时间】:2012-01-26 10:05:45
【问题描述】:
使用 CameraCaptureTask 拍摄照片。
问题:当我在 ReduceSize() 函数中使用流 photostream = g_MS 时,流与 g_stream = e.ChosenPhoto 不同。
我想在 ReduceSize() 函数中缩小照片尺寸后得到与 g_stream = e.ChosenPhoto 相同的流。
stream g_stream;
BitmapImage g_bmp;
MemoryStream g_MS = new MemoryStream();
void task_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
{
try
{
if (e.TaskResult == TaskResult.OK)
{
g_bmp = new BitmapImage();
g_bmp.CreateOptions = BitmapCreateOptions.DelayCreation;
g_bmp.SetSource(e.ChosenPhoto);
g_stream = e.ChosenPhoto;
ReduceSize();
}
}
catch (Exception ex)
{
}
}
private void ReduceSize()
{
string m_Filenm = "Testing.jpg";
WriteableBitmap wb = new WriteableBitmap(g_bmp);
//--wb read byte into memorystream
System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, g_MS,800, 640, 0, 100);
g_MS.Seek(0, SeekOrigin.Begin);
stream photostream = g_MS;
//------------------ Save
//--save in the photo Library under Saved Photo Collection
MediaLibrary ML = new MediaLibrary();
ML.SavePicture(m_Filenm, g_MS);
}
【问题讨论】:
标签: windows-phone-7