Bra*_*yac 1 c# writeablebitmapex windows-8
我正在使用WriteableBitmapEx库编辑使用Windows 8 Pro平板电脑的凸轮拍摄的图像。每次调用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.
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
尝试使用内置方法来创建您的方法WriteableBitmap。
WriteableBitmap tmpImage = await BitmapFactory.New(1, 1).FromStream(memoryStream);
tmpImage.GetPixel(1, 1);
Run Code Online (Sandbox Code Playgroud)
这应确保在访问图像之前将其加载到WriteableBitmap中。
| 归档时间: |
|
| 查看次数: |
851 次 |
| 最近记录: |