2013-04-19 2 views
1

WriteableBitmapEx 라이브러리를 사용하여 Windows 8 Pro에서 태블릿의 캠으로 찍은 이미지를 편집하고 있습니다. 여기,() 함수를 내가하는 getPixel 호출 할 때마다 AccessViolationException 받고 있어요 코드입니다 : 내가 잘못 무엇WriteableBitmapEx를 사용하여 픽셀 색상에 액세스 할 때 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. 

은?

답변

4

기본 제공 방법을 사용하여 WriteableBitmap을 대신 사용해보세요.

WriteableBitmap tmpImage = await BitmapFactory.New(1, 1).FromStream(memoryStream); 
tmpImage.GetPixel(1, 1); 

이렇게하면 이미지를 액세스하기 전에 WriteableBitmap에로드해야합니다.

+0

효과가있었습니다. 고맙습니다. – Branyac

+0

당신은 환영합니다 :) – keyboardP