在CameraCaptureTask
拍攝圖像後,應將其上傳到服務器。上傳的服務器端JPG似乎有正確的文件大小,但已損壞。此外,imageBuffer
似乎將所有字節設置爲0.任何有關下面代碼錯誤的想法?在silverlight中上傳時JPG損壞
if (bitmapImage != null) {
// create WriteableBitmap object from captured BitmapImage
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);
using (MemoryStream ms = new MemoryStream())
{
writeableBitmap.SaveJpeg(ms, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100);
imageBuffer = new byte[ms.Length];
ms.Read(imageBuffer, 0, imageBuffer.Length);
ms.Dispose();
}
}
「SaveJpeg」是否將流重新定位回位置0?否則,流的位置不會*在保存的圖像之後*? –