2

Nokia Imaging SDK를 사용하여 WP8 앱을 개발 중입니다. 이미지에 필터 효과를 추가하고 WriteableBitmap으로 렌더링하려고합니다.WriteableBitmapRenderer.RenderAsync() ArgumentException "값이 예상되는 범위 내에 있지 않습니다."

await renderer.RenderAsync(); 

ArgumentException가 발생합니다 :

Value does not fall within the expected range 

내가 생각이 라인이 처리 될 때 모두가 잘 진행되지만,

private async void PhotoChosen(object sender, PhotoResult photoResult) 
    { 
     if (photoResult != null) 
     { 
      BitmapImage bitmap = new BitmapImage(); 
      bitmap.SetSource(photoResult.ChosenPhoto); 

      WriteableBitmap wb = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight); 

      StreamImageSource source = new StreamImageSource(photoResult.ChosenPhoto); 

      var effects = new FilterEffect(source); 
      effects.Filters = new IFilter[] { new SketchFilter() }; 
      var renderer = new WriteableBitmapRenderer(effects, wb); 

      await renderer.RenderAsync(); 
     } 
    } 

: 여기

내 코드입니다 IImageProvider effects 또는 WriteableBitmap wb을 만드는 데 실수했습니다.

누구든지이 문제가있어 문제를 발견 했습니까? 감사합니다 :)

답변

4

StreamImageSource의 소스로 설정하기 전에 스트림 위치를 설정해야합니다.

BitmapImage bitmap = new BitmapImage(); 
bitmap.SetSource(photoResult.ChosenPhoto); 

WriteableBitmap wb = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight); 

photoResult.ChosenPhoto.Position = 0; 

StreamImageSource source = new StreamImageSource(photoResult.ChosenPhoto); 

bitmap.SetSource(photoResult.ChosenPhoto)을 호출했기 때문에이 작업을 수행해야합니다. 이는 스트림이 이미 한 번 읽혀 졌음을 의미하므로 스트림의 맨 끝에 위치합니다. StreamImageSource가이를 읽으려고하면 이미 끝났습니다. 따라서 "값이 예상되는 범위 내에 들지 않습니다."

+0

문제가 해결되었습니다. 타이 매우! :디 – McSIME

관련 문제