我正在使用WriteableBitmapEx库编辑用Windows8专业版平板电脑的摄像头拍摄的图像。每次我调用GetPixel()函数时都会得到一个AccessViolationException,下面是代码:
Windows.Media.Capture.MediaCapture captureMgr = new MediaCapture();
await captureMgr.InitializeAsync();
IRandomAccessStream memoryStream = new InMemoryRandomAccessStream();
await captureMgr.CapturePhotoToStreamAsync(imageProperties, memoryStream);
await memoryStream.FlushAsync();
memoryStream.Seek(0);
WriteableBitmap tmpImage = new WriteableBitmap(1, 1);
tmpImage.SetSource(memoryStream);
tmpImage.GetPixel(1, 1); // An AccessViolationException occurs.我哪里做错了?
发布于 2013-04-20 00:35:24
尝试使用内置方法来创建您的WriteableBitmap。
WriteableBitmap tmpImage = await BitmapFactory.New(1, 1).FromStream(memoryStream);
tmpImage.GetPixel(1, 1);这将确保您的映像在被访问之前已加载到WriteableBitmap中。
https://stackoverflow.com/questions/16109097
复制相似问题