首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用WriteableBitmapEx访问像素颜色时的AccessViolationException

使用WriteableBitmapEx访问像素颜色时的AccessViolationException
EN

Stack Overflow用户
提问于 2013-04-20 00:17:25
回答 1查看 906关注 0票数 1

我正在使用WriteableBitmapEx库编辑用Windows8专业版平板电脑的摄像头拍摄的图像。每次我调用GetPixel()函数时都会得到一个AccessViolationException,下面是代码:

代码语言:javascript
复制
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.

我哪里做错了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-20 00:35:24

尝试使用内置方法来创建您的WriteableBitmap

代码语言:javascript
复制
WriteableBitmap tmpImage = await BitmapFactory.New(1, 1).FromStream(memoryStream);  
tmpImage.GetPixel(1, 1);

这将确保您的映像在被访问之前已加载到WriteableBitmap中。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16109097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档